#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
using namespace std;
int main()
{
int i,j,k,q,p,r,s,u;
int x,y,m,a,b,c,d,e,f,g,h;
float n,l,o,t;
int greentea = 45;
int cocoa = 35;
int thaitea = 45;
int milktea = 35;
int choice;
loop:
printf("\n");
printf("\n\n***-------Drink Shop-------***\n\n");
printf("Main Menu\n");
printf("\n\nSelect choice menu: \n1. Green tea=45 bath \n2. Cocoa=35 bath \n3. Thai tea=45 bath \n4. Milk tea=35 bath \n5. Exit\n\n");
scanf("%d",&choice);
switch(choice)
{
case 5 :exit(0);}
switch(choice)
{
case 1 :printf("\n\n1. Green tea=45 bath: ");
printf("\n\nEnter number of products:");
scanf("%d",&p);
printf("Enter amount of money: ");
scanf("%f",&n);
i=p*greentea;
printf("\n\nThe total number of items = %d",p);
printf("\n\nThe total number of money = %d",i);
m=n-i;
printf("\n\nTorn = %d Bath \n\n",m);
a=m/1000;
printf("\nBank 1,000 = %d Bath ",a);
b=m00;
c=b/100;
if(c>=5)
{
printf("\nBank 500 = %d ",1);
c=c-5;
}else{
}
printf("\nBank 100 %d ",c);
d=m0;
e=d/10;
if(e>=5){
printf("\nBank 50 = %d ",1);
e=e-5;
}else{
}
f=e/2;
printf("\nBank 20 = %d ",f);
g=e%2;
printf("\nCoin 10 = %d ",g);
h=m;
if(h>=5){
printf("\nCoin 5 = %d ",1);
h=h-5;
}else{
}
printf("\nCoin 1 =%d ",h);
break;
case 2 :printf("\n\n2. cocoa=35 bath: ");
printf("\n\nEnter number of products:");
scanf("%d",&q);
printf("\n\nEnter amount of money: ");
scanf("%f",&l);
j= q*cocoa;
printf("\n\nThe total number of items = %d",q);
printf("\n\nThe total number of money = %d",j);
m=l-j;
printf("\n\nTorn = %d Bath \n\n",m);
a=m/1000;
printf("\nBank 1,000 = %d ",a);
b=m00;
c=b/100;
if(c>=5)
{
printf("\nBank 500 = %d ",1);
c=c-5;
}else{
}
printf("\nBank 100 %d ",c);
d=m0;
e=d/10;
if(e>=5){
printf("\nBank 50 = %d ",1);
e=e-5;
}else{
}
f=e/2;
printf("\nBank 20 = %d ",f);
g=e%2;
printf("\nCoin 10 = %d ",g);
h=m;
if(h>=5){
printf("\nCoin 5 = %d ",1);
h=h-5;
}else{
}
printf("\nCoin 1 =%d ",h);
break;
case 3 :printf("\n\n3. Thai Tea=45 bath: ");
printf("\n\nEnter number of products:");
scanf("%d",&r);
printf("Enter amount of money: ");
scanf("%f",&o);
k=r*thaitea;
printf("\n\nThe total number of items = %d",r);
printf("\n\nThe total number of money = %d",k);
m=o-k;
printf("\n\nTorn = %d Bath \n\n",m);
a=m/1000;
printf("\nBank 1,000 = %d Bath ",a);
b=m00;
c=b/100;
if(c>=5)
{
printf("\nBank 500 = %d ",1);
c=c-5;
}else{
}
printf("\nBank 100 %d ",c);
d=m0;
e=d/10;
if(e>=5){
printf("\nBank 50 = %d ",1);
e=e-5;
}else{
}
f=e/2;
printf("\nBank 20 = %d ",f);
g=e%2;
printf("\nCoin 10 = %d ",g);
h=m;
if(h>=5){
printf("\nCoin 5 = %d ",1);
h=h-5;
}else{
}
printf("\nCoin 1 =%d ",h);
break;
case 4 :printf("\n\n4. Milk Tea=35 bath: ");
printf("\n\nEnter number of products:");
scanf("%d",&s);
printf("Enter amount of money: ");
scanf("%f",&t);
u=s*milktea;
printf("\n\nThe total number of items = %d",s);
printf("\n\nThe total number of money = %d",u);
m=t-u;
printf("\n\nTorn = %d Bath \n\n",m);
a=m/1000;
printf("\nBank 1,000 = %d Bath ",a);
b=m00;
c=b/100;
if(c>=5)
{
printf("\nBank 500 = %d ",1);
c=c-5;
}else{
}
printf("\nBank 100 %d ",c);
d=m0;
e=d/10;
if(e>=5){
printf("\nBank 50 = %d ",1);
e=e-5;
}else{
}
f=e/2;
printf("\nBank 20 = %d ",f);
g=e%2;
printf("\nCoin 10 = %d ",g);
h=m;
if(h>=5){
printf("\nCoin 5 = %d ",1);
h=h-5;
}else{
}
printf("\nCoin 1 =%d ",h);
break;
}
system("pause");
return 0;
}
จะเปลี่ยนจาก printf เป็น cout ยังไงหรอคะ ลองหลายครั้งแล้วค่ะไม่ได้ซักที
#include<iomanip>
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
using namespace std;
int main()
{
int i,j,k,q,p,r,s,u;
int x,y,m,a,b,c,d,e,f,g,h;
float n,l,o,t;
int greentea = 45;
int cocoa = 35;
int thaitea = 45;
int milktea = 35;
int choice;
loop:
printf("\n");
printf("\n\n***-------Drink Shop-------***\n\n");
printf("Main Menu\n");
printf("\n\nSelect choice menu: \n1. Green tea=45 bath \n2. Cocoa=35 bath \n3. Thai tea=45 bath \n4. Milk tea=35 bath \n5. Exit\n\n");
scanf("%d",&choice);
switch(choice)
{
case 5 :exit(0);}
switch(choice)
{
case 1 :printf("\n\n1. Green tea=45 bath: ");
printf("\n\nEnter number of products:");
scanf("%d",&p);
printf("Enter amount of money: ");
scanf("%f",&n);
i=p*greentea;
printf("\n\nThe total number of items = %d",p);
printf("\n\nThe total number of money = %d",i);
m=n-i;
printf("\n\nTorn = %d Bath \n\n",m);
a=m/1000;
printf("\nBank 1,000 = %d Bath ",a);
b=m00;
c=b/100;
if(c>=5)
{
printf("\nBank 500 = %d ",1);
c=c-5;
}else{
}
printf("\nBank 100 %d ",c);
d=m0;
e=d/10;
if(e>=5){
printf("\nBank 50 = %d ",1);
e=e-5;
}else{
}
f=e/2;
printf("\nBank 20 = %d ",f);
g=e%2;
printf("\nCoin 10 = %d ",g);
h=m;
if(h>=5){
printf("\nCoin 5 = %d ",1);
h=h-5;
}else{
}
printf("\nCoin 1 =%d ",h);
break;
case 2 :printf("\n\n2. cocoa=35 bath: ");
printf("\n\nEnter number of products:");
scanf("%d",&q);
printf("\n\nEnter amount of money: ");
scanf("%f",&l);
j= q*cocoa;
printf("\n\nThe total number of items = %d",q);
printf("\n\nThe total number of money = %d",j);
m=l-j;
printf("\n\nTorn = %d Bath \n\n",m);
a=m/1000;
printf("\nBank 1,000 = %d ",a);
b=m00;
c=b/100;
if(c>=5)
{
printf("\nBank 500 = %d ",1);
c=c-5;
}else{
}
printf("\nBank 100 %d ",c);
d=m0;
e=d/10;
if(e>=5){
printf("\nBank 50 = %d ",1);
e=e-5;
}else{
}
f=e/2;
printf("\nBank 20 = %d ",f);
g=e%2;
printf("\nCoin 10 = %d ",g);
h=m;
if(h>=5){
printf("\nCoin 5 = %d ",1);
h=h-5;
}else{
}
printf("\nCoin 1 =%d ",h);
break;
case 3 :printf("\n\n3. Thai Tea=45 bath: ");
printf("\n\nEnter number of products:");
scanf("%d",&r);
printf("Enter amount of money: ");
scanf("%f",&o);
k=r*thaitea;
printf("\n\nThe total number of items = %d",r);
printf("\n\nThe total number of money = %d",k);
m=o-k;
printf("\n\nTorn = %d Bath \n\n",m);
a=m/1000;
printf("\nBank 1,000 = %d Bath ",a);
b=m00;
c=b/100;
if(c>=5)
{
printf("\nBank 500 = %d ",1);
c=c-5;
}else{
}
printf("\nBank 100 %d ",c);
d=m0;
e=d/10;
if(e>=5){
printf("\nBank 50 = %d ",1);
e=e-5;
}else{
}
f=e/2;
printf("\nBank 20 = %d ",f);
g=e%2;
printf("\nCoin 10 = %d ",g);
h=m;
if(h>=5){
printf("\nCoin 5 = %d ",1);
h=h-5;
}else{
}
printf("\nCoin 1 =%d ",h);
break;
case 4 :printf("\n\n4. Milk Tea=35 bath: ");
printf("\n\nEnter number of products:");
scanf("%d",&s);
printf("Enter amount of money: ");
scanf("%f",&t);
u=s*milktea;
printf("\n\nThe total number of items = %d",s);
printf("\n\nThe total number of money = %d",u);
m=t-u;
printf("\n\nTorn = %d Bath \n\n",m);
a=m/1000;
printf("\nBank 1,000 = %d Bath ",a);
b=m00;
c=b/100;
if(c>=5)
{
printf("\nBank 500 = %d ",1);
c=c-5;
}else{
}
printf("\nBank 100 %d ",c);
d=m0;
e=d/10;
if(e>=5){
printf("\nBank 50 = %d ",1);
e=e-5;
}else{
}
f=e/2;
printf("\nBank 20 = %d ",f);
g=e%2;
printf("\nCoin 10 = %d ",g);
h=m;
if(h>=5){
printf("\nCoin 5 = %d ",1);
h=h-5;
}else{
}
printf("\nCoin 1 =%d ",h);
break;
}
system("pause");
return 0;
}