พอดีรันออกได้นะคะ แต่อาจารย์ต้องการหน้าใบเสร็จให้มีเฉพาะรายการที่เราเลือก ทำไม่ได้อะคะช่วยดูให้หน่อยนะคะ
หน้าใบเสร็จจะอยู่ในตารางอันที่2นะคะไม่ใช่อันแรก อันแรกคือโชว์ว่าเรามีรายการเมนูอะคะ
#include<iostream>
#include<stdio.h>
#include<windows.h>
void gotoxy(short x,short y){
COORD pos = {x,y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}
int main()
{
int herprice,micprice,chaprice,burprice,dioprice,louprice,gucprice;
int herqty,micqty,chaqty,burqty,dioqty,louqty,gucqty;
float hertotal,mictotal,chatotal,burtotal,diototal,loutotal,guctotal,total;
char ch;
char sale[30];
char buyer[30];
int answer;
herprice = 16000;
micprice = 2000;
chaprice = 78000;
burprice = 15000;
dioprice = 45000;
louprice = 35000;
gucprice = 30000;
herqty = 0;
micqty = 0;
chaqty = 0;
burqty = 0;
dioqty = 0;
louqty = 0;
gucqty = 0;
system("cls");
gotoxy(40,1);printf(" ---------------------------SHOP BAG BEAUTY--------------------------\n");
gotoxy(40,2);printf(" ___________________________________________________________________\n");
gotoxy(40,3);printf(" |_______________________________Menu________________________________|\n");
gotoxy(40,4);printf(" |1.Hermes Bag-----[1]------|Price---------------------------16000 B.|\n\n");
gotoxy(40,5);printf(" |2.Michael Bag----[2]------|Price----------------------------2000 B.|\n\n");
gotoxy(40,6);printf(" |3.Chanel Bag-----[3]------|Price---------------------------78000 B.|\n\n");
gotoxy(40,7);printf(" |4.Burberry Bag---[4]------|Price---------------------------15000 B.|\n\n");
gotoxy(40,8);printf(" |5.Dior Bag-------[5]------|Price---------------------------45000 B.|\n\n");
gotoxy(40,9);printf(" |6.Louis Bag------[6]------|Price---------------------------35000 B.|\n\n");
gotoxy(40,10);printf(" |7.Gucci Bag------[7]------|Price---------------------------30000 B.|\n");
gotoxy(40,11);printf(" |___________________________________________________________________|\n");
gotoxy(40,12);printf(" |_________________________Exit with Program [P]_____________________|\n");
gotoxy(20,16);printf("sale : ");scanf("%s",&sale);
gotoxy(20,18);printf("buyer:");scanf("%s",&buyer);
do{
printf("\nPlease Select choice ");scanf("%d",&answer);
switch(answer)
{
case 1: printf("\n1.Hermes Bag\n");
printf("\n Enter price : %d",herprice);
printf("\n Enter qty :");scanf("%d",&herqty);
hertotal = herprice * herqty;
printf("Hermes Bag Total = %.2f",hertotal);
break;
case 2 : printf("\n2.Michael Bag\n");
printf("\n Enter price : %d",micprice);
printf("\n Enter qty :");scanf("%d",&micqty);
mictotal = micprice * micqty;
printf("Michael Bag Total = %.2f",mictotal);
break;
case 3 : printf("\n3.Chanel Bag\n");
printf("\n Enter price : %d",chaprice);
printf("\n Enter qty :");scanf("%d",&chaqty);
chatotal = chaprice * chaqty;
printf("Chanel Bag Total = %.2f",chatotal);
break;
case 4 : printf("\n4.Burberry Bag\n");
printf("\n Enter price : %d",burprice);
printf("\n Enter qty :");scanf("%d",&burqty);
burtotal = burprice * burqty;
printf("Burberry Bag Total = %.2f",burtotal);
break;
case 5 : printf("\n5.Dior Bag\n");
printf("\n Enter price : %d",dioprice);
printf("\n Enter qty :");scanf("%d",&dioqty);
diototal = dioprice * dioqty;
printf("Dior Bag Total = %.2f",diototal);
break;
case 6 : printf("\n6.Louis Bag\n");
printf("\n Enter price : %d",louprice);
printf("\n Enter qty :");scanf("%d",&louqty);
loutotal = louprice * louqty;
printf("Louis Bag Total = %.2f",loutotal);
break;
case 7 : printf("\n7.Gucci Bag\n");
printf("\n Enter price : %d",gucprice);
printf("\n Enter qty :");scanf("%d",&gucqty);
guctotal = gucprice * gucqty;
printf("Gucci Bag Total = %.2f",guctotal);
break;
default : printf("You choice is incorrect");
}
total = hertotal+mictotal+chatotal+burtotal+diototal+loutotal+guctotal;
printf("\n\nExit Program Press y or Y");scanf("%c",&ch);
} while ((ch != 'Y') && (ch != 'y'));
system("cls");
gotoxy(45,1);printf(" ______________________SHOP BAG BEAUTY_________________________\n");
gotoxy(45,2);printf(" 1.Hermes Bag : qty %d price : %d total %.2f Baht \n\n",herqty,herprice,hertotal);
gotoxy(45,3);printf(" 2.Michael Bag : qty %d price : %d total %.2f Baht \n\n",micqty,micprice,mictotal);
gotoxy(45,4);printf(" 3.Chanel Bag : qty %d price : %d total %.2f Baht \n\n",chaqty,chaprice,chatotal);
gotoxy(45,5);printf(" 4.Burberry Bag: qty %d price : %d total %.2f Baht \n\n",burqty,burprice,burtotal);
gotoxy(45,6);printf(" 5.Dior Bag : qty %d price : %d total %.2f Baht \n\n",dioqty,dioprice,diototal);
gotoxy(45,7);printf(" 6.Louis Bag : qty %d price : %d total %.2f Baht \n\n",louqty,louprice,loutotal);
gotoxy(45,8);printf(" 7.Gucci Bag : qty %d price : %d total %.2f Baht \n\n",gucqty,gucprice,guctotal);
gotoxy(45,10);printf(" Total : %.2f Baht\n",total);
gotoxy(45,11);printf("______________________________________________________________\n\n");
gotoxy(45,12);printf("____________________Exit with Program [P]_____________________\n\n");
gotoxy(45,16);printf("sale : %s \n",sale);
gotoxy(45,17);printf("buyer: %s \n",buyer);
}
พอดีทำโปรเจคเกี่ยวกับภาษซีโปรแกรม DEV C++คะ ช่วยดูให้หน่อยคะ
หน้าใบเสร็จจะอยู่ในตารางอันที่2นะคะไม่ใช่อันแรก อันแรกคือโชว์ว่าเรามีรายการเมนูอะคะ
#include<iostream>
#include<stdio.h>
#include<windows.h>
void gotoxy(short x,short y){
COORD pos = {x,y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}
int main()
{
int herprice,micprice,chaprice,burprice,dioprice,louprice,gucprice;
int herqty,micqty,chaqty,burqty,dioqty,louqty,gucqty;
float hertotal,mictotal,chatotal,burtotal,diototal,loutotal,guctotal,total;
char ch;
char sale[30];
char buyer[30];
int answer;
herprice = 16000;
micprice = 2000;
chaprice = 78000;
burprice = 15000;
dioprice = 45000;
louprice = 35000;
gucprice = 30000;
herqty = 0;
micqty = 0;
chaqty = 0;
burqty = 0;
dioqty = 0;
louqty = 0;
gucqty = 0;
system("cls");
gotoxy(40,1);printf(" ---------------------------SHOP BAG BEAUTY--------------------------\n");
gotoxy(40,2);printf(" ___________________________________________________________________\n");
gotoxy(40,3);printf(" |_______________________________Menu________________________________|\n");
gotoxy(40,4);printf(" |1.Hermes Bag-----[1]------|Price---------------------------16000 B.|\n\n");
gotoxy(40,5);printf(" |2.Michael Bag----[2]------|Price----------------------------2000 B.|\n\n");
gotoxy(40,6);printf(" |3.Chanel Bag-----[3]------|Price---------------------------78000 B.|\n\n");
gotoxy(40,7);printf(" |4.Burberry Bag---[4]------|Price---------------------------15000 B.|\n\n");
gotoxy(40,8);printf(" |5.Dior Bag-------[5]------|Price---------------------------45000 B.|\n\n");
gotoxy(40,9);printf(" |6.Louis Bag------[6]------|Price---------------------------35000 B.|\n\n");
gotoxy(40,10);printf(" |7.Gucci Bag------[7]------|Price---------------------------30000 B.|\n");
gotoxy(40,11);printf(" |___________________________________________________________________|\n");
gotoxy(40,12);printf(" |_________________________Exit with Program [P]_____________________|\n");
gotoxy(20,16);printf("sale : ");scanf("%s",&sale);
gotoxy(20,18);printf("buyer:");scanf("%s",&buyer);
do{
printf("\nPlease Select choice ");scanf("%d",&answer);
switch(answer)
{
case 1: printf("\n1.Hermes Bag\n");
printf("\n Enter price : %d",herprice);
printf("\n Enter qty :");scanf("%d",&herqty);
hertotal = herprice * herqty;
printf("Hermes Bag Total = %.2f",hertotal);
break;
case 2 : printf("\n2.Michael Bag\n");
printf("\n Enter price : %d",micprice);
printf("\n Enter qty :");scanf("%d",&micqty);
mictotal = micprice * micqty;
printf("Michael Bag Total = %.2f",mictotal);
break;
case 3 : printf("\n3.Chanel Bag\n");
printf("\n Enter price : %d",chaprice);
printf("\n Enter qty :");scanf("%d",&chaqty);
chatotal = chaprice * chaqty;
printf("Chanel Bag Total = %.2f",chatotal);
break;
case 4 : printf("\n4.Burberry Bag\n");
printf("\n Enter price : %d",burprice);
printf("\n Enter qty :");scanf("%d",&burqty);
burtotal = burprice * burqty;
printf("Burberry Bag Total = %.2f",burtotal);
break;
case 5 : printf("\n5.Dior Bag\n");
printf("\n Enter price : %d",dioprice);
printf("\n Enter qty :");scanf("%d",&dioqty);
diototal = dioprice * dioqty;
printf("Dior Bag Total = %.2f",diototal);
break;
case 6 : printf("\n6.Louis Bag\n");
printf("\n Enter price : %d",louprice);
printf("\n Enter qty :");scanf("%d",&louqty);
loutotal = louprice * louqty;
printf("Louis Bag Total = %.2f",loutotal);
break;
case 7 : printf("\n7.Gucci Bag\n");
printf("\n Enter price : %d",gucprice);
printf("\n Enter qty :");scanf("%d",&gucqty);
guctotal = gucprice * gucqty;
printf("Gucci Bag Total = %.2f",guctotal);
break;
default : printf("You choice is incorrect");
}
total = hertotal+mictotal+chatotal+burtotal+diototal+loutotal+guctotal;
printf("\n\nExit Program Press y or Y");scanf("%c",&ch);
} while ((ch != 'Y') && (ch != 'y'));
system("cls");
gotoxy(45,1);printf(" ______________________SHOP BAG BEAUTY_________________________\n");
gotoxy(45,2);printf(" 1.Hermes Bag : qty %d price : %d total %.2f Baht \n\n",herqty,herprice,hertotal);
gotoxy(45,3);printf(" 2.Michael Bag : qty %d price : %d total %.2f Baht \n\n",micqty,micprice,mictotal);
gotoxy(45,4);printf(" 3.Chanel Bag : qty %d price : %d total %.2f Baht \n\n",chaqty,chaprice,chatotal);
gotoxy(45,5);printf(" 4.Burberry Bag: qty %d price : %d total %.2f Baht \n\n",burqty,burprice,burtotal);
gotoxy(45,6);printf(" 5.Dior Bag : qty %d price : %d total %.2f Baht \n\n",dioqty,dioprice,diototal);
gotoxy(45,7);printf(" 6.Louis Bag : qty %d price : %d total %.2f Baht \n\n",louqty,louprice,loutotal);
gotoxy(45,8);printf(" 7.Gucci Bag : qty %d price : %d total %.2f Baht \n\n",gucqty,gucprice,guctotal);
gotoxy(45,10);printf(" Total : %.2f Baht\n",total);
gotoxy(45,11);printf("______________________________________________________________\n\n");
gotoxy(45,12);printf("____________________Exit with Program [P]_____________________\n\n");
gotoxy(45,16);printf("sale : %s \n",sale);
gotoxy(45,17);printf("buyer: %s \n",buyer);
}