Jul 8, 2014 at 3:30pm UTC
#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
int md, age, ctr ;
double charge, avgchg, totchg;
cout << "Enter id no :" ;
cin >> md ;
cout << left << fixed << setprecision(2) ;
ctr = 0 ;
totchg = 0 ;
while (md > 0)
{
ctr++;
cout << "Enter Age :" ;
cin >> age ;
if (age < 20)
charge = 10.50 ;
else if (age < 35)
charge = 30.00 ;
else
charge = 50.75 ;
totchg = totchg + charge ;
cout << endl << "Member ID : " << md << endl ;
cout << "Serial No :" << ctr << endl;
cout << "Age :" << age << endl;
cout << "Charge :" << charge << endl;
cout << endl << "Member ID :" ;
cin >> md ;
}
avgchg = totchg / ctr ;
cout << "Total number of members is :" << ctr << endl;
cout << "Average charge is : " << avgchg << endl;
system("pause");
return 0;
}
Like the program comes out
Enter id no : 304 (how do i get rid of this line)
Age : 34 ( when i print out my receipt)
MemberID : 304
Serial No : 1
Age : 34
Charge : $30.00
how do i get rid of the command which the user inputs
Jul 8, 2014 at 4:48pm UTC
You are using cout for two purposes: (1) to prompt the user for input and (2) to print the receipt. Maybe you should print the receipt to a separate file?