我是编程新手,我想知道是否有人可以帮助我解决这个问题?它似乎处于一个连续的循环中,我一直在更改它并尝试不同的方法近一个小时,非常感谢您的帮助。
#include "stdafx.h"
#include <conio.h>
#include <iostream>
#include <iomanip>
#include "float.h"
#include <stack>
using namespace std;
using std::stack;
int _tmain(int argc, _TCHAR* argv[])
{
{
char treatment_types, anymore_treatments, anymore_visits, treatment_type[15], answer/*, ftype, wtype, ctype, etype, rtype, itype*/;
double levy = 15, fcharge, wcharge, ccharge, echarge, rcharge, icharge, cost, totalcost, totalincome;
int quantity, noofpatients, total_qtyf, total_qtyw, total_qtyc, total_qtye, total_qtyr, total_qtyi;
cout << "\n Enter treatment type (F,W,C,E,R,I) : ";
cin >> treatment_types;
cout << "\n Enter quantity of treatments : ";
cin >> quantity;
switch (treatment_types)
{
case 'F': fcharge = 27.50;
cost = fcharge;
total_qtyf = quantity;
cost = quantity*cost;
totalcost = fcharge + cost;
/*totalcost = fcharge * total_qtyf;*/
break;
case 'W': wcharge = 40.00;
cost = wcharge;
total_qtyw = quantity;
cost = quantity*cost;
totalcost = wcharge + cost;
/* totalcost = quantity + total_qtyw;*/
break;
case 'C': ccharge = 210.00;
cost = ccharge;
total_qtyc = quantity;
cost = quantity*cost;
totalcost = ccharge + cost;
/*totalcost = quantity + total_qtyc;*/
break;
case 'E': echarge = 25.00;
cost = echarge;
total_qtye = quantity;
cost = quantity*cost;
totalcost = echarge + cost;
/* totalcost = quantity + total_qtye; */
break;
case 'R': rcharge = 145.00;
cost = rcharge;
total_qtyr = quantity;
cost = quantity*cost;
totalcost = rcharge + cost;
/* totalcost = quantity + total_qtyr;*/
break;
case 'I': icharge = 7.50;
cost = icharge;
total_qtyi = quantity;
cost = quantity*icharge;
totalcost = cost + icharge;
/*totalcost = quantity + total_qtyi; */
break;
}
cout << "\n " << cost + 15;
/* do
{*/
cout << "\n\n""Any more treatments [Y/N] :";
cin >> answer;
while (answer == 'Y')
{
cout << "\nEnter treatment type( F,W,C,E,R,I) : ";
cin >> treatment_type;
cout << "\nEnter Quantity : ";
cin >> quantity;
cout << "\n " << cost * quantity;
cout << "\n\n""Any more treatments [Y/N] :";
cin >> answer;
}
while (answer == 'N')
{
cout << "Anymore visits? [Y/N]: ";
cin >> answer;
}
while (answer == 'N')
{
cout << "Your bill is : " << totalcost << endl;
}
{ while (answer == 'Y')
cout << "\nEnter treatment type( F,W,C,E,R,I) : ";
cin >> treatment_type;
}
}
//while (true);
_getche();
return 0;
}
//}