Alisha Naaz http://vualisha.blogspot.com E-mail: vualisha@gmail.com

......Indian Songs.......

>

Saturday, January 30, 2010

CS 504 Ass Solution

// Medicine Daily Sale system with unit price

#include
#include

const float TAX=.06;

void menu();

int main()
{
float total=0;
bool done=false;
char choice;
menu();
cout << setiosflags(ios::showpoint) << setiosflags(ios::fixed) << setprecision(2);
while (!done) {
cout << "Your current sub-total is: rupees" << total << endl;
cout << "Enter your selection (q to quit, ? for menu): ";
cin >> choice;
cout << endl;
switch (choice) {
case '?':
menu();
break;
case 'S': case 's':
cout << "sugar medicine, 7.50/rs" << endl << endl;
total+=7.5;
break;
case 'C': case 'c':
cout << "cancer medicine, 2.00/rs" << endl << endl;
total+=2;
break;
case 'B': case 'b':
cout << "Breast medicine, 1.75/rs" << endl << endl;
total+=1.75;
break;
case 'R': case 'r':
cout << "Regular medicine, 2.50/rs" << endl << endl;
total+=2.5;
break;
case 'L': case 'l':
cout << "Local medicine, 4.75/rs" << endl << endl;
total+=4.75;
break;
case 'X': case 'x':
cout << "Cancel, start over." << endl << endl;
total=0;
break;
case 'T': case 't':
cout << "Sub-total: " << total << endl;
cout << "+ Tax : " << total*TAX << endl;
cout << "Total : " << total+total*TAX << endl << endl;
break;
case 'Q': case 'q':
done=true;
break;
default:
menu();
}
}
}

void menu() {
cout << endl;
cout << "S - sugar medicine 7.50/rs" << endl;
cout << "C - cancer medicine 2.00/rs" << endl;
cout << "B - breast medicine 1.75/rs" << endl;
cout << "R - Regular medicine 2.50/rs" << endl;
cout << "L - Local medicine 4.75/rs" << endl;
cout << "X - cancel and start over" << endl;
cout << "T - total the sale" << endl;
cout << endl;
cout << "All items are subject to sales tax. 6%.";
cout << endl << endl;
}


----------------------------------------------------
//medicine scale
----------------------------------------------------

using namespace std;



int main()
{
cout << "Enter sales for this week: " << endl << endl;
int nmedicineArray[5];
int nmedicineArray[5];
int nInp;
int nScale1 = 0 ; //200/399
int nScale2 = 0; //400/699
int nScale3 = 0; //700/999
int nScale4 = 0; //1000/1499
int nScale5 = 0; //<1500


for(int n = 0; n < 5; n++)
{
cout << "Day " << n+1 << ": rs";
cin >> nInp;
nmedicineArray[n] = nInp;
nmedicineArray[n] = ( nmedicineArray[n] * 0.09 ) + 200;

if(nmedicineArray[n] <= 399)
nScale1 += 1;
else if(nmedicineArray[n] >= 400 && nmedicineArray[n] <=699)
nScale2 +=1;
else if(nmedicineArray[n] >= 700 && nmedicineArray[n] <=999)
nScale3 +=1;
else if(nmedicineArray[n] >= 1000 && nmedicineArray[n] <=1499)
nScale4 +=1;
else
nScale5 +=1;
}

cout << endl;
cout << "rs200-rs399................ " << nScale1 << " sales." << endl;
cout << "rs400-rs699................ " << nScale2 << " sales." << endl;
cout << "rs700-rs999................ " << nScale3 << " sales." << endl;
cout << "rs1000-rs1499.............. " << nScale4 << " sales." << endl;
cout << "rs1500 +.................. " << nScale5 << " sales." << endl << endl;

}
----------------------------------------------------
//add & search
----------------------------------------------------


static const int MAXIMUM_RECORDS = 300;
int Service::servNo = 0;

vector vecMedicine;

Service *newServ = 0;
ServiceDAO servDAO;
vector vecService;

void main()
{
vecService.assign(MAXIMUM_RECORDS, newServ);
vecService = servDAO.readFile(vecService, newServ);
do
{
// at here display the main menu
// switch(choice)
// case 1 goto addService();break;
// case 2 goto searchService();break;
// case 3 goto listService();break;
//http://vustudents.ning.com/
}
servDAO.saveFile(vecService);
}

void addService()
{
newServ = new Regular();
vecService[Service::servNo] = newServ;
// back to main menu //http://vustudents.ning.com/
}

void searchService()
{
newServ = new Regular();

// enter a valid medicine input
vecService[x]->setMedicine(vecMedicine[iPosMed]);

// enter a valid dosage input
// pusback the value into tempVec
vector tempVec;
vecService[pos]->setDosage(tempVec);
//http://vustudents.ning.com/
// back to main menu
}

void listService()
{
system("cls");
int x;
int z = 0;
int iMed = 0;
string temp;
gotoxy(0,8);cout << "No.";
gotoxy(5,8);cout << "Type ";
gotoxy(55,8);cout << "Medicine(s)";
gotoxy(0,9);cout << "-------------------------------------------------------------------------------";
for (x=1;x {
if(vecService[x] != NULL)
{
gotoxy(0,9+x+z);cout << x;
gotoxy(5,9+x+z);cout << vecService[x]->getServType().c_str();
if(vecService[x]->getMedicine().size() != 0)
{
for(iMed = 0; iMed < vecService[x]->getMedicine().size(); iMed++)
{
if(iMed == 0)
{
temp = vecService[x]->getMedicine()[iMed].getMedName();
}
else
{
temp += ", " + vecService[x]->getMedicine()[iMed].getMedName();
}
gotoxy(55,9+x+z);cout << temp.c_str();
}
}
else
{
gotoxy(55,9+x+z);cout << "<>";
}

}
else
{
--z;
}
}
}

---------------------------------------------------------
// Calculation
---------------------------------------------------------


using std::cout;
using std::cin;
using std::endl;
using std::string;
using std::getline;
using std::fixed;
using std::setprecision;
using std::transform;

int main()
{
string stateId = "";
double sale = 0.0;
double shipping = 0.0;

//enter input data
//http://vustudents.ning.com/
cout << "Two-character state ID: ";
getline(cin, stateId);
transform(stateId.begin(), stateID.end(),
stateId.begin(), toupper);
cout << "Sale amount: ";
cin >> sale;

//calculate shipping charge
shipping = sale * .01;
//add $5 to Tennessee shipments
//http://vustudents.ning.com/
if (stateId == "TN")
shipping = shipping + 5;
//end if

//display shipping charge
cout << fixed << setprecision(2);
cout << "Shipping: " << shipping << endl;

return 0;
} //end of main function


----------------------------------------------
//Report
----------------------------------------------
ofstream r;
ifstream t;

void credits();
void menu1();
void menu2();
void menu3();
void terms();

class mediccal store
{
public:
int medicineId;
char na[20];
int s1,s2,s3,s4,s5;
char g[10];
int t;
int p;
void input()
{
gotoxy(1,5);
cout<<"\tENTER medicineId OF THE Medicine :";
cin>>medicineId;
cout<<"\tENTER NAME OF THE medicine :";
gets(na);
cout<<"\n\n\tENTER Sale OF THE sold medicines OUT OF 100";
cin>>5;
cout<<"\n";
cout<<"\tENTER sale IN medicine1: ";
cin>>s1;
cout<<"\n";
cout<<"\tENTER sale IN medicine2: ";
cin>>s2;
cout<<"\n";
cout<<"\tENTER sale IN medicine3: ";
cin>>s3;
cout<<"\n";
cout<<"\tENTER sale IN medicine4:";
cin>>s4;
cout<<"\n";
cout<<"\tENTER sale IN medicine5:";
cin>>s5;
cout<<"\n";
cleardevice();
t=s1+s2+s3+s4+s5;
p=t/5;
gotoxy(1,1);
}

void output()
{
cout<<"\n";
cout<<" "< cout<<" "< cout<<" "< cout<<"\t";
}
}s[30];

int i,n;
void writes()
{
clrscr();
cleardevice();
cout<<"\n";
cout<<"\tENTER THE NUMBER OF RECORDS TO BE CREATED :";
cin>>n;
cleardevice();
for(i=0;i {
s[i].input();
if(s[i].p>=95)
strcpy(s[i].g,"A1");
if(s[i].p>=90&&s[i].p<95)
strcpy(s[i].g,"A2");
if(s[i].p>=80&&s[i].p<90)
strcpy(s[i].g,"B1");
if(s[i].p>=70&&s[i].p<80)
strcpy(s[i].g,"B2");
if(s[i].p>=60&&s[i].p<70)
strcpy(s[i].g,"C1");
if(s[i].p>=50&&s[i].p<60)
strcpy(s[i].g,"C2");
if(s[i].p>=40&&s[i].p<50)
strcpy(s[i].g,"D1");
if(s[i].p<40)
strcpy(s[i].g,"D2");
r.write((char*)&s[i],sizeof(s[i]));
}
}

void append()
{
clrscr();
cleardevice();
cout<<"\n";
int k;
cout<<"\t\t\t*-----------*"<<"\n";
cout<<"\t\t\t| APPENDING |"<<"\n";
cout<<"\t\t\t*-----------*"<<"\n"<<"\n";
cout<<"\tENTER THE NUMBER OF RECORDS TO BE APPENDED :";
cin>>k;
for(i=0;i {
s[i].input();
if(s[i].p>=95)
strcpy(s[i].g,"A1");
if(s[i].p>=90&&s[i].p<95)
strcpy(s[i].g,"A2");
if(s[i].p>=80&&s[i].p<90)
strcpy(s[i].g,"B1");
if(s[i].p>=70&&s[i].p<80)
strcpy(s[i].g,"B2");
if(s[i].p>=60&&s[i].p<70)
strcpy(s[i].g,"C1");
if(s[i].p>=50&&s[i].p<60)
strcpy(s[i].g,"C2");
if(s[i].p>=40&&s[i].p<50)
strcpy(s[i].g,"D1");
if(s[i].p<40)
strcpy(s[i].g,"D2");
r.write((char*)&s[i],sizeof(s[i]));
}
getch();
n+=k;
}

void search()
{
clrscr();
cleardevice();
char name[20];
int flag=0;
cout<<"\n";
cout<<"\t\t\t*-----------*"<<"\n";
cout<<"\t\t\t| SEARCHING |"<<"\n";
cout<<"\t\t\t*-----------*"<<"\n"<<"\n";

step:
cout<<"\n\tENTER THE Medicine Name TO BE SEARCHED :";
gets(name);
cout<<"\n";
cout<<"medicineId Medicine Name Quantity Sold PERCENTAGE PRICE"<<"\n";
for(i=0;i {
t.read((char *) &s[i],sizeof(s[i]));
if(strcmp(name,s[i].na)==0)
{
flag=1;
s[i].output();
break;
}
}
if(flag==0)
{
cleardevice();
cout<<"\tSORRY\n";
cout<<"\tTHE NAME DOES NOT EXIST.\n";
}
getch();
}

void update()
{
clrscr();
cleardevice();
cout<<"\t\t\t*--------------*"<<"\n";
cout<<"\t\t\t| UPDATED LIST |"<<"\n";
cout<<"\t\t\t*--------------*"<<"\n"<<"\n";
cout<<"medicineId Medicine Name Quantity Sold PERCENTAGE PRICE "<<"\n";
cout<<"-----------------------------------------------------------"<<"\n";
for(i=0;i {
if(s[i].p<=40.0)
s[i].t=s[i].t+(s[i].t/10);
s[i].p=s[i].t/5.0;
if(s[i].p>=50.0&&s[i].p<60.0)
strcpy(s[i].g,"C2");
if(s[i].p>=40.0&&s[i].p<50.0)
strcpy(s[i].g,"D1");
if(s[i].p<40.0)
strcpy(s[i].g,"Failed");
r.write((char*)&s[i],sizeof(s[i]));
s[i].output();
}
getch();
}

void sort()
{
clrscr();
cleardevice();
xii tp;
cout<<"\t\t\t*-------------*"<<"\n";
cout<<"\t\t\t| SORTED LIST |"<<"\n";
cout<<"\t\t\t*-------------*"<<"\n"<<"\n";
cout<<"medicineId Medicine Name Quantity Sold PERCENTAGE PRICE "<<"\n";
cout<<"---------------------------------------------------------"<<"\n";
for(i=0;i {
t.read((char *) &s[i],sizeof(s[i]));
for(i=0;i { for(int j=i+1;j { if(strcmp(s[i].na,s[j].na)>0)
{ tp=s[i];
s[i]=s[j];
s[j]=tp;
}
}
}
for(i=0;i s[i].output();
}
getch();
}

void failed()
{
cleardevice();
cout<<"\t**----------------------------------------------------------**"<<"\n";
cout<<"\t|| THE LIST OF MEDICINE WHICH FAILED IN SALE MORE THAN ONE CUSTOMER ||"<<"\n";
cout<<"\t**----------------------------------------------------------**\n\n";
cout<<"MEDICINE ID MEDICINE NAME Quantity Sold PERCENTAGE PRICE"<<"\n";
cout<<"-------------------------------------------------------"<<"\n";
for(i=0;i {
int c=0;
t.read((char *) &s[i],sizeof(s[i]));
if (s[i].s1<40)
c++;
if (s[i].s2<40)
c++;
if (s[i].s3<40)
c++;
if (s[i].s4<40)
c++;
if (s[i].s5<40)
c++;
if(c>=2)
{
s[i].output();
}
}
getch();
}

void reads()
{
clrscr();
cleardevice();
cout<<"\n";
cout<<"\t**------------------------------------------------**"<<"\n";
cout<<"\t|| THE REPORT CARD OF MEDICINE SOLD IN MEDICAL STORE ||"<<"\n";
cout<<"\t**------------------------------------------------**"<<"\n"<<"\n";
cout<<"MEDICINE ID MEDICINE NAME Quantity Sold PERCENTAGE PRICE"<<"\n";
cout<<"--------------------------------------------------------"<<"\n";
for(i=0;i {
t.read((char *) &s[i],sizeof(s[i]));
s[i].output();
}
getch();
}

void terms()
{
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver,&gmode,"");
errorcode = graphresult();
if (errorcode !=grOk) /* an error code occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch;
exit(1); /* terminate with an error code */
}
char chc;
rectangle(1,1,getmaxx(),getmaxy());
settextstyle(GOTHIC_FONT,VERT_DIR,5);
settextjustify(LEFT_TEXT,CENTER_TEXT); //Was actually- settextjustify(LEFT_TEXT,CENTER_TEXT,5);
outtextxy(50,240,"REPORT CARD");
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,5);
outtextxy(240,50,"SELECT A TERM");
outtextxy(240,90,"OF YOUR CHOICE.");
outtextxy(240,105," ......................................");
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,4);
setbkcolor(BLACK);
outtextxy(300,170,"1.Ist TERM");
outtextxy(300,220,"2.IInd TERM");
outtextxy(300,270,"3.IIIrd TERM");
outtextxy(300,320,"4.EXIT");
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,3);
outtextxy(400,400,"ENTER CHOICE");
chc=getch();
switch(chc)
{
case '1':cleardevice();
menu1();
break;
case '2':cleardevice();
menu2();
break;
case '3':cleardevice();
menu3();
break;
case '4':cleardevice();
credits();
exit(0);
default :clrscr();
cleardevice();

settextstyle(TRIPLEX_FONT,HORIZ_DIR,5);
outtextxy(220,210,"WRONG CHOICE !");
outtextxy(170,270,"PLEASE TRY AGAIN.");
sleep(2);
cleardevice();
terms();
}
closegraph();
}

void credits()
{
cleardevice();
setbkcolor(4);
gotoxy(33,6);
cout<<"-:Created By:-";
for(int i=70;i>28;i--)
{
gotoxy(i,8);
cout<<"1: Programmer 1 ";
delay(70);
}
for(i=70;i>28;i--)
{
gotoxy(i,10);
cout<<"2: Programmer 2 ";
delay(70);
}
gotoxy(28,25);
cout<<"Press any key to exit...";
getch();
exit(0);
}

/***********************************menu1************************************/

void menu1()
{
cleardevice();
char ch;
back:
settextstyle(GOTHIC_FONT,VERT_DIR,5);
settextjustify(LEFT_TEXT,CENTER_TEXT);
outtextxy(50,240,"REPORT CARD");
settextstyle(SANS_SERIF_FONT,VERT_DIR,4);
setbkcolor(BLACK);
settextjustify(LEFT_TEXT,CENTER_TEXT);
outtextxy(110,240,"Ist TERM");
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,4);
outtextxy(290,50,"1.MAKE REPORT CARD");
outtextxy(290,90,"2.APPEND NAMES");
outtextxy(290,130,"3.SORT NAMES");
outtextxy(290,170,"4.SEARCH A NAME");
outtextxy(290,210,"5.UPDATE GRADE");
outtextxy(290,250,"6.VIEW REPORT CARD");
outtextxy(290,290,"7.LIST OF FAILURES");
outtextxy(290,330,"8.MAIN MENU");
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,3);
outtextxy(400,420,"ENTER CHOICE");
ch=getch();

switch(ch)
{
case '1':
r.open("report_1");
writes();
r.close();
cleardevice();
goto back;

case '2':
r.open("report_1",ios::app|ios::out);
append();
r.close();
cleardevice();
goto back;

case '3':
t.open("report_1");
sort();
t.close();
cleardevice();
goto back;

case '4':
t.open("report_1");
search();
t.close();
cleardevice();
goto back;

case '5':
r.open("report_1",ios::end);
update();
r.close();
cleardevice();
goto back;

case '6':
t.open("report_1");
reads();
t.close();
cleardevice();
goto back;

case '7':
t.open("report_1");
failed();
t.close();
cleardevice();
goto back;

case '8':
closegraph();
terms();

default :clrscr();
cleardevice();
settextstyle(TRIPLEX_FONT,HORIZ_DIR,5);
outtextxy(220,240,"WRONG CHOICE !");
outtextxy(190,280,"PLEASE TRY AGAIN.");
void sleep(2);
cleardevice();
goto back;
}
}

/***************************************menu2********************************************/
void menu2()
{
cleardevice();
char ch;
back:
settextstyle(GOTHIC_FONT,VERT_DIR,5);
settextjustify(LEFT_TEXT,CENTER_TEXT);
outtextxy(50,240,"REPORT CARD");
settextstyle(SANS_SERIF_FONT,VERT_DIR,4);
setbkcolor(BLACK);
settextjustify(LEFT_TEXT,CENTER_TEXT);
outtextxy(110,240,"IInd TERM");
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,4);
outtextxy(290,50,"1.MAKE REPORT CARD");
outtextxy(290,90,"2.APPEND NAMES");
outtextxy(290,130,"3.SORT NAMES");
outtextxy(290,170,"4.SEARCH A NAME");
outtextxy(290,210,"5.UPDATE GRADE");
outtextxy(290,250,"6.VIEW REPORT CARD");
outtextxy(290,290,"7.LIST OF FAILURES");
outtextxy(290,330,"8.MAIN MENU");
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,3);
outtextxy(400,420,"ENTER CHOICE");
ch=getch();

switch(ch)
{
case '1':
r.open("report_2");
writes();
r.close();
cleardevice();
goto back;

case '2':
r.open("report_2",ios::app|ios::out);
append();
r.close();
cleardevice();
goto back;

case '3':
t.open("report_2");
sort();
t.close();
cleardevice();
goto back;

case '4':
t.open("report_2");
search();
t.close();
cleardevice();
goto back;

case '5':
r.open("report_2",ios::end);
update();
r.close();
cleardevice();
goto back;

case '6':
t.open("report_2");
reads();
t.close();
cleardevice();
goto back;

case '7':
t.open("report_2");
failed();
t.close();
cleardevice();
goto back;

case '8':
closegraph();
terms();

default :clrscr();
cleardevice();
settextstyle(TRIPLEX_FONT,HORIZ_DIR,5);
outtextxy(220,240,"WRONG CHOICE !");
outtextxy(190,280,"PLEASE TRY AGAIN.");
sleep(2);
cleardevice();
goto back;
}
}

/*********************************menu3**************************************/
void menu3()
{
cleardevice();
char ch;
back:
settextstyle(GOTHIC_FONT,VERT_DIR,5);
settextjustify(LEFT_TEXT,CENTER_TEXT);
outtextxy(50,240,"REPORT CARD");
settextstyle(SANS_SERIF_FONT,VERT_DIR,4);
setbkcolor(BLACK);
settextjustify(LEFT_TEXT,CENTER_TEXT);
outtextxy(110,240,"IIIrd TERM");
settextstyle(SANS_SERIF_FONT,0,4);
outtextxy(290,50,"1.MAKE REPORT CARD");
outtextxy(290,90,"2.APPEND NAMES");
outtextxy(290,130,"3.SORT NAMES");
outtextxy(290,170,"4.SEARCH A NAME");
outtextxy(290,210,"5.UPDATE GRADE");
outtextxy(290,250,"6.VIEW REPORT CARD");
outtextxy(290,290,"7.LIST OF FAILURES");
outtextxy(290,330,"8.MAIN MENU");
settextstyle(SANS_SERIF_FONT,0,3);
//http://vustudents.ning.com/
outtextxy(400,420,"ENTER CHOICE");
ch=getch();

switch(ch)
{
case '1':
r.open("report_3");
writes();
r.close();
cleardevice();
goto back;
case '2':
r.open("report_3",ios::app|ios::out);
append();
r.close();
cleardevice();
goto back;

case '3':
t.open("report_3");
sort();
t.close();
cleardevice();
goto back;

case '4':
t.open("report_3");
search();
t.close();
cleardevice();
goto back;

case '5':
r.open("report_3",ios::end);
update();
r.close();
cleardevice();
goto back;

case '6':
t.open("report_3");
reads();
t.close();
cleardevice();
goto back;

case '7':
t.open("report_3");
failed();
t.close();
cleardevice();
goto back;

case '8':
closegraph();
terms();

default :clrscr();
cleardevice();
settextstyle(TRIPLEX_FONT,HORIZ_DIR,5);
outtextxy(220,240,"WRONG CHOICE !");
outtextxy(190,280,"PLEASE TRY AGAIN.");
sleep(2);
cleardevice();
goto back;
}
}

/**********************************main**************************************/
void main()
{
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver,&gmode,"");
errorcode = graphresult();
if (errorcode != grOk) /*an error occurred*/
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch;
exit(1); /* terminate with an error code */
}

settextstyle(SANS_SERIF_FONT,HORIZ_DIR,5);
rectangle(1,1,getmaxx(),getmaxy());
setbkcolor(9);
outtextxy(300,100,"A");
delay(2000);
outtextxy(200,170,"PROJECT ON");
delay(2000);
outtextxy(95,240,"REPORT CARD MAKING");
delay(2000);
for(int i=0;i<360;i++)
{
int ellipse(320,240,0,i,300,200);
delay(12);
}
closegraph();
terms();
}
//Thanx

0 comments:

Searching Video

Vu Alisha Search

VUalisha Followers (Jion Now and Get Extra benefits)

Contact Us

My photo
E-mail: vualisha@gmail.com