اقتباس//Exercise#3//Mail Order House Program
#include <iostream.h>
int main()
{
int product;
int quantity;
double cost=0;
double pr;
cout<<"Enter pairs of item numbers and quantities\n";
cout<<"Enter -1 for the item number to end input: ";
cin>>productcin>>quantity>>quantity;
while (product!= -1){
switch(product){
case 1:
pr=2.98;
break;
case 2:
pr=4.50;
break;
case 3:
pr=9.98;
break;
case 4:
pr=4.49;
break;
default:
pr=6.87;
break;
}
cost+=quantity*pr;
cout<<"Enter pairs of item numbers and quantities\n";
cout<<" Enter -1 for the item number to end input: ";
cin>>product>>quantity;
}
cout<<"The total retail value was: "<<cost<<"\n";
return 0;
}
السلام عليكم ورحمة الله وبركاته
كتبت هذا البرنامج... ولكن أحتاج لان أعدله بحيث اذا اخترت القيمة -1 لا يجب أن أدخل ال quantity حتى يعرض ال total
أي كهذه الشاشة مثلا
اقتباسEnter pairs of item numbers and quantitiesEnter -1 for the item number to end input:1 12
Enter pairs of item numbers and quantities
Enter -1 for the item number to end input:2 20
Enter pairs of item numbers and quantities
Enter -1 for the item number to end input:3 88
Enter pairs of item numbers and quantities
Enter -1 for the item number to end input:4 99
Enter pairs of item numbers and quantities
Enter -1 for the item number to end input:5 139
Enter pairs of item numbers and quantities
Enter -1 for the item number to end input:-1
The total retail value was:2403.44
Press any key to continue
أرجو المساعدة والرد بسرعة
ولكم جزيل الشكر