【发布时间】:2017-10-23 22:54:27
【问题描述】:
到目前为止,我们在课堂上编写的每个程序都以默认的“按任意键继续...”结尾,我该如何更改?我试过使用
cout”无)
但它仍然显示“按任意键继续”,我输入一个键。有什么想法吗?
这是我到目前为止所拥有的(请随时指出我如何在其他领域也有所改进!) `
#include <iostream>
using namespace std;
#include <string>
using namespace std;
int main()
{
//Declaring my varibles
double persons = 0;
double tier1 = 125;
double tier2 = 100;
double tier3 = 75;
double cost = 0;
string hyphens = "";
system("cls");
cout << "-------------------------------------------------- " << endl;
cout << "Computer Programming Seminar" << endl;
cout << "-------------------------------------------------- " << endl<<endl;
cout << "Please enter the number of registrants: ";
cin >> persons;
cout << hyphens << endl;
if (0 < persons && persons < 6)
cost = persons * tier1;
else if (5 < persons && persons < 21)
cost = persons *tier2;
else if (persons >= 21)
cost = persons*tier3;
else
{
cost = 0;
cout << "Invalid Entry" <<endl << endl;
}
cout << "Total Amount Owed for the Seminar: $" << cost << endl;
cout << "-------------------------------------------------- " << endl;
cout << endl << endl << "Press any key to end the Seminar Program";
system("pause>nul");
return 0;
【问题讨论】: