R
Richard
I am new to C++ and I do not understand the formatting code very well. I
need to format my output to look like this:
Movie Name: "Death Grip"
Adult Tickets Sold: 378
Child Tickets Sold: 127
Gross Box Office Profit: $ 2673.00
Net Box Office Profit: $ 534.60
Amount Paid To Movie C.:$ 2138.40
The C++ code are below. I cannot make the result look like the above for
some reason because I do not get the format code:
#include <iostream>
#include <iomanip>
using namespace std;
void main()
{
float AdultTicket=6, ChildrenTicket=3, ATicket, CTicket,
GrossProfit,NetProfit,AmountPaidCompany;
char MovieTitle[80];
// ask for information
cout<<"what is the name of the movie?"<<endl;
cin.getline(MovieTitle,80);
cout<<endl;
cout<<"How many adult tickets were sold?"<<endl;
cin>>ATicket;
cout<<endl;
cout<<"How many Children tickets were sold?"<<endl;
cin>>CTicket;
cout<<endl;
//calculating profit
GrossProfit=(ATicket*AdultTicket)+(CTicket*ChildrenTicket);
NetProfit=GrossProfit* float(.2);
AmountPaidCompany=GrossProfit* float(.8);
//Display data
cout<<setprecision(2);
cout.setf(ios::fixed | ios::showpoint);
cout<<"Movie Name:"<<setw(20)<<MovieTitle<<endl;
cout<<"Adult Tickets Sold:"<<setw(12)<<int(ATicket)<<endl;
cout<<"Children Tickets Sold:"<<setw(9)<<int(CTicket)<<endl;
cout<<"Gross Box Office Profit:"<<setw(7)<<GrossProfit<<endl;
cout<<"Net Box Office Profit:"<<setw(9)<<NetProfit<<endl;
cout<<"Amount Paid to Movie Co.:"<<setw(6)<<AmountPaidCompany<<endl;
}
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
need to format my output to look like this:
Movie Name: "Death Grip"
Adult Tickets Sold: 378
Child Tickets Sold: 127
Gross Box Office Profit: $ 2673.00
Net Box Office Profit: $ 534.60
Amount Paid To Movie C.:$ 2138.40
The C++ code are below. I cannot make the result look like the above for
some reason because I do not get the format code:
#include <iostream>
#include <iomanip>
using namespace std;
void main()
{
float AdultTicket=6, ChildrenTicket=3, ATicket, CTicket,
GrossProfit,NetProfit,AmountPaidCompany;
char MovieTitle[80];
// ask for information
cout<<"what is the name of the movie?"<<endl;
cin.getline(MovieTitle,80);
cout<<endl;
cout<<"How many adult tickets were sold?"<<endl;
cin>>ATicket;
cout<<endl;
cout<<"How many Children tickets were sold?"<<endl;
cin>>CTicket;
cout<<endl;
//calculating profit
GrossProfit=(ATicket*AdultTicket)+(CTicket*ChildrenTicket);
NetProfit=GrossProfit* float(.2);
AmountPaidCompany=GrossProfit* float(.8);
//Display data
cout<<setprecision(2);
cout.setf(ios::fixed | ios::showpoint);
cout<<"Movie Name:"<<setw(20)<<MovieTitle<<endl;
cout<<"Adult Tickets Sold:"<<setw(12)<<int(ATicket)<<endl;
cout<<"Children Tickets Sold:"<<setw(9)<<int(CTicket)<<endl;
cout<<"Gross Box Office Profit:"<<setw(7)<<GrossProfit<<endl;
cout<<"Net Box Office Profit:"<<setw(9)<<NetProfit<<endl;
cout<<"Amount Paid to Movie Co.:"<<setw(6)<<AmountPaidCompany<<endl;
}
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]