標題:
購物系統(二)
[打印本頁]
作者:
周政輝
時間:
2018-3-10 14:30
標題:
購物系統(二)
本帖最後由 周政輝 於 2018-3-24 12:41 編輯
新增 "請輸入商品代碼:" 與 "數量:" 的選項,
並於結帳時計算出總共多少錢, 執行畫面如下圖所示.
[attach]3553[/attach]
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[7]={"(1)搖控汽車","(2)玩具車","(3)遙控直升機","(4)足球","(5)籃球","(6)棒球","(7)玩具熊"} ;
int num[7]={500,1000,540,450,660,5,10} ;
cout<<"玩具店"<<endl;
cout<<"價目表"<<endl;
for(int i=0;i<7;i++)
{
cout<<name[i]<<num[i]<<endl;
}
cout<<endl;
int productnumber=0;
int count=0;
int total=0;
cout<<"輸入-1離開"<<endl;
while (true)
{
cout<<"請輸入商品代碼"<<endl;
cin>>productnumber;
if(productnumber==-1)
{
break;
}
cout<<"請輸入數量"<<endl;
cin>>count;
total=total+num[productnumber-1]*count;
}
cout<<"總金額為"<<total;
system("pause");
return 0;
}
複製代碼
作者:
林峻安
時間:
2018-3-10 14:58
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
cout<<"智能玩具店"<<endl;
string num[7]={"(1)遙控車","(2)遙控飛機","(3)足球 ","(4)拼圖 ","(5)籃球 ","(6)玩具槍","(7)娃娃"};
int n[7]={750,550,555,78,885,1999,85};
for(int i=0;i<7;i++)
{
cout<<num[i]<<"\t";
cout<<n[i]<<"\t";
cout<<endl;
}
int a=0;
int z=0;
int w=0;
cout<<"輸入-1離開:"<<endl;
while(true)
{
cout<<"商品代碼:"<<endl;
cin>>a;
if(a==-1)
{
break;
}
cout<<"數量:"<<endl;
cin>>z;
w= w+n[a-1]*z;
}
cout<<"總金額:"<<w<<endl;
system("pause");
return 0;
}
複製代碼
作者:
王駿愷
時間:
2018-3-10 14:59
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string name[7]={"(1)搖控汽車","(2)玩具車","(3)遙控直升機","(4)足球","(5)籃球","(6)棒球","(7)玩具熊"} ;
int num[7]={500,1000,540,450,660,5,10} ;
cout<<"玩具店"<<endl;
cout<<"價目表"<<endl;
for(int i=0;i<7;i++)
{
cout<<name[i]<<num[i]<<endl;
}
cout<<endl;
int productnumber=0;
int count=0;
int total=0;
cout<<"輸入-1離開"<<endl;
while (true)
{
cout<<"請輸入商品代碼"<<endl;
cin>>productnumber;
cout<<"請輸入數量"<<endl;
cin>>count;
if(productnumber==-1)
{
total=total+num[count-1]*count;
break;
}
};
cout<<"總金額為"<<total;
system("pause");
return 0;
}
複製代碼
作者:
吳秉翰
時間:
2018-3-10 15:09
本帖最後由 吳秉翰 於 2018-3-10 15:13 編輯
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string item []=
{
"(1)遙控汽車 ",
"(2)飛機模型 ",
"(3)足球 ",
"(4)拼圖 ",
"(5)玩具槍 ",
"(6)可愛玩偶 ",
"(7)籃球 ",
};
int num []={450,550,325,200,660,150,380};
cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl<<"[商品價目表]"<<endl;
for(int i=0;i<7;i++)
{
cout<<item[i]<<num[i]<<"元"<<"\t"<<endl;
}
int pn = 0;
int count =0;
int total = 0;
while(true)
{
cout<<"代碼:";
cin>>pn;
if(pn==8)
{
break;
}
cout<<"數目:";
cin>>count;
total=total+num[pn-1]*count;
}
cout<<total<<"元"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
湯東緯
時間:
2018-3-10 15:12
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
string item []={
"(1)遙控汽車 ",
"(2)飛機模型 ",
"(3)足球 ",
"(4)拼圖 ",
"(5)玩具槍 ",
"(6)可愛玩偶 ",
"(7)籃球 "};
int num []={450,550,325,200,660,150,380};
cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl;
cout<<"[商品價目表]"<<endl;
for(int i=0;i<7;i++)
{
cout<<item[i]<<num[i]<<"元"<<"\t"<<endl;
}
int total=0;
int pn=0;
int count=0;
cout<<"輸入-1後離開"<<endl;
while(true)
{
cout<<"請輸入商品代碼"<<endl;
cin>>pn;
if(pn==-1){
break;
}
cout<<"數目:";
cin>>count;
total=total+num[pn-1]*count;
}
cout<<total<<"元"<<endl;
system("pause");
return 0;
}
複製代碼
作者:
黃安立
時間:
2018-3-10 15:15
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
cout<<"智能玩具店"<<endl;
string name [7]={"(1)遙控汽車","(2)遙控飛機","(3)足球","(4)評圖","(5)玩具槍","(6)可愛玩偶","(7)籃球"};
int num[7]={450,550,325,200,660,150,380};
for (int i=0;i<7;i++)
{
cout<<name[i]<<"\t";
cout<<num[i]<<endl;
}
cout<<endl;
int productnumber=0;
int count=0;
int total=0;
cout<<"請輸入-1離開"<<endl;
while(true)
{
cout<<"商店代碼"<<endl;
cin>>productnumber;
if(productnumber==-1)
{break;
}
cout<<"數量"<<endl;
cin>>count;
total=total+num[count-1]*count;
}
cout<<"總金"<<total<<endl;
system("pause");
return 0;
}
複製代碼
作者:
戴嘉禾
時間:
2018-3-10 15:36
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
cout<<"☆★☆智能玩具店☆★☆"<<endl;
string f[7]=
{
"(1)遙控汽車",
"(2)飛機模型",
"(3)足球 ",
"(4)拼圖 ",
"(5)玩具槍 ",
"(6)可愛玩偶",
"(7)籃球 "
};
int n[7]={450,550,325,200,660,150,380};
for(int i=0;i<7;i++)
{
cout<<f[i]<<"\t"<<n[i]<<"元"<<endl;
}
int num=0;
int count=0;
int total=0;
cout<<"輸入0結帳"<<endl;
while(true)
{
cout<<"請輸入商品代碼"<<endl;
cin>>num;
if(num==0)
{
break;
}
cout<<"請輸入數量"<<endl;
cin>>count;
total=total+n[num-1]*count;
}
cout<<"總金額:"<<total<<endl;
system("pause");
return 0;
}
複製代碼
作者:
鄭楀諺
時間:
2018-3-17 13:30
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
int total=0;
int num,many;
string name[7]={"搖控汽車 ","飛機模型 ","足球 ","拼圖 ","玩具槍 ","可愛玩偶 ","籃球 "};
int price[7]={450,550,325,200,660,150,380};
cout<<" 智能玩具店"<<endl;
cout<<"商品\t\t金額"<<endl;
for(int i=0;i<=6;i++)
{
cout<<"("<<i+1<<")"<<name[i]<<price[i]<<"元";
cout<<endl;
}
cout<<"輸入(8)結帳"<<endl;
while(true)
{
cout<<"請輸入商品代碼: ";
cin>>num;
if(num==8)
break;
cout<<"數量: ";
cin>>many;
total=total+(price[num-1]*many);
}
cout<<endl;
cout<<"總共"<<total<<"元!";
system("PAUSE");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2