this is a program that s intended to appear all at once and the input should start at the initial service with the total appearing at the bottom of the screen indented, but I can't manage because it only appears line by line once ans 'y'...need advice ...tnx
# include <iostream>
using namespace std;
const int hc=50; // price for hair cut
const int cp=500; // price for cellophane
const int ho=150; // price for hot oil
const int hs=250; // price for hair spa
const int hr=1500;
const int hd=400;
const int ham=500;
const int fs=80;
const int mc=50;
const int pc=60;
double n=.10; // Discount for total amout
double s=.20; // Discount for total amount
double g=.30;
double p=.40;
double v=.50;
int main()
{
int tot=0;int dis = 0;int nt=0;
char y,mem;
cout<<"Did the customer avail the following services:(Y/N):" << endl;cout << "total: " << tot<<endl;
cout<<"HairCut P 50.00: ";cin >> y;if (y=='Y' || y=='y') tot=hc;cout << "total: " << tot<<endl;
cout<<"HotOil P 150.00: ";cin >> y;if (y=='Y' || y=='y') tot+=ho;cout << "total: " << tot<<endl;
cout<<"HairSpa P 250.00: ";cin >> y;if (y=='Y' || y=='y') tot+=hs;cout << "total: " << tot<<endl;
cout<<"HairRebond P 1500.00: ";cin >> y;if (y=='Y' || y=='y') tot+=hr;cout << "total: " << tot<<endl;
cout<<"Cellophane P 500: ";cin >> y;if (y=='Y' || y=='y') tot+=cp;cout << "total: " << tot<<endl;
cout<<"HairDye P 400.00: ";cin >> y;if (y=='Y' || y=='y') tot+=hd;cout << "total: " << tot<<endl;
cout<<"Hair and Makeup P 500.00: ";cin >> y;if (y=='Y' || y=='y') tot+=ham;cout << "total: " << tot<<endl;
cout<<"FootSpa P 80.00: ";cin >> y;if (y=='Y' || y=='y') tot+=fs;cout << "total: " << tot<<endl;
cout<<"Manicure P 50.00: ";cin >> y;if (y=='Y' || y=='y') tot+=mc;cout << "total: " << tot<<endl;
cout<<"Pedicure P 60.00: ";cin >> y; if (y=='Y' || y=='y') tot+=pc;cout << "total: " << tot<<endl;
cout << "total: " << tot << endl << endl;
cout <<"MEMBERSHIP TYPE: ";cout<<"\n";
cout <<"VIP";cout<<"\n";
cout <<"Platinum";cout<<"\n";
cout <<"Gold";cout<<"\n";
cout <<"Silver";cout<<"\n";
cout <<"NewMember";cout<<"\n";
cout <<"Enter Customer Membership Type: ";
cin>>mem;
if (mem=='g')
dis=g*tot;
nt=tot-dis;
if (mem=='s')
dis=s*tot;
nt=tot-dis;
if (mem=='p')
dis=p*tot;
nt=tot-dis;
if (mem=='v')
dis=v*tot;
nt=tot-dis;
if (mem=='n')
dis=n*tot;
nt=tot-dis;
cout<<"\n";
cout << "Total: " << tot << endl << endl;
cout <<"Discounted Price: "<< dis <<endl <<endl;
cout <<"NewTotal: "<< nt<<endl <<endl;
return 0;
}
You need to flush the buffer before your cin. This forces every thing out to the screen.
Either use endl which flushes and gives a newline or cout.flush() if you don't want a new line character. It would also be better to use endl instead of "\n".
The cin stream is tied to cout so any time you use it the output is automatically flushed. Arguments rage both ways but the only difference between '\n' and endl is the latter adds a flush to the former (and maybe a sync).
I'm not sure I understand what it is you are trying to do. Do you mean that you are trying to place the total on a different part of the display than where the user is answering questions?