<分区>
我是编程新手。在我的期末考试中,我被告知要编写一个包含 if else while do 和数组的程序。我真的很困惑,为什么在我的程序中,我必须计算价格,它没有显示,它只是循环回到我的订购代码。有什么想法吗?
cout <<"COKE \t\t\t-Php 30 \t" ;
cout << setw (50) <<" Carbonated softdrink by Coca-Cola Company in 2.5L."<<endl;
cout <<"SPRITE \t\t-Php 30 \t";
cout<< setw(50) <<" A colorless, lemon and lime-flavored soft drink in 2.5L."<<endl;
cout <<"ICED TEA\t\t-Php 30 \t ";
cout <<setw (20) <<"Houseblend iced tea in 1L pitcher."<<endl;
cout <<"COFFEE \t\t\t-Php 25 \t";
cout << setw (55) << " A brewed drink prepared from roasted coffee beans in a cup."<<endl;
cout <<"BOTTLED WATER \t\t-Php 20 \t";
cout <<setw (25) <<" A purified drinking water in 500mL." <<endl;
cout <<"-----------------------------------------------------------------------------------------------------------------------" <<endl <<endl;
cout <<"1 \t Order Now" <<endl;
cout <<"0 \t Back" <<endl <<endl;
cout <<"Enter the number of your choice: ";
cin >> ow;
if (ow==1){
history[length] = "Order";
length += 1;
while(ow!=0){
system ("cls");
cout <<"\nRICE MEAL " <<setw (30) << "DRINKS\n" <<endl;
cout <<"Hotsilog \t-Php 45 \t" <<setw(15) <<"Coke \t\t\t-Php 30" <<endl;
cout <<"Tocilog \t-Php 45 \t" << setw(15) <<"Sprite \t\t-Php 30" <<endl;
cout <<"Tapsilog \t-Php 45 \t" << setw(15) <<"Iced Tea \t\t-Php 30" << endl;
cout <<"Porksilog \t-Php 50 \t" << setw(15) <<"Coffee \t\t\t-Php 25" <<endl;
cout <<"Chickensilog \t-Php 55 \t" <<setw (15) <<"Bottled Water \t\t-Php 20" << endl;
string product [50];
string note [50];
int qty [10];
int price [10];
int e;
int totalprice = 0;
cout <<"\nNumber of Product Name you will need: ";
cin>> e;
cin.ignore();
cout <<"\nFill in the order form based on above.\n";
cout <<"Orders not mention above will be disregarded.\n\n";
for (int i=0; i<e; i++){
cout <<"Enter the 'Name' of the product you will buy: ";
getline (cin, product[i]);
cout <<"Additional Note (Press Enter if no additional note): ";
getline (cin, note [i]);
cout <<"Quantity: ";
cin >> qty[i] ;
cout <<"Price: ";
cin >> price[i];
cin.ignore();
system ("cls");
}
// system ("cls");
cout <<"Your Product's List " <<endl << endl;
for (int j=0; j<e; j++){
cout <<"Product Name: " << product [j] <<endl;
cout <<"Quantity:" << qty[j]<< endl;
cout <<"Price: "<< price [j] << endl <<endl;
totalprice = totalprice + (qty [j]*price[j]);
cout << "Total Price: " <<totalprice;
} \\This is the line that I am having trouble with, it won't show up when I enter the number of food I input.
}
}
}
}
}
return 0;
}
如有任何帮助,我们将不胜感激!