Help With Classwork?

I am supposed to be making a program for football tickets sales, but I am not getting the out put I should. Here is my current code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//Todd Dunaway
//10/13/2014
//Football Ticket Sales Problem

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
//Step 3: Declare Variables
double boxTicketCost, sideTicketCost, premTicketCost, genTicketCost;
int boxTicketsSold, sideTicketsSold, premTicketsSold, genTicketsSold;
double boxTicketsTotalMoney, sideTicketsTotalMoney, premTicketsTotalMoney, genTicketsTotalMoney;
int totalTicketsSold;
double totalMoneyMade;
//Step 4: Output and Input
cout<<"Cost of a box ticket: $"<<endl;
cin>>boxTicketCost;
cout<<"Number of box tickets sold: "<<endl;
cin>>boxTicketsSold;
cout<<"Cost of a sideline ticket: $"<<endl;
cin>>sideTicketCost;
cout<<"Number of side tickets sold: "<<endl;
cin>>sideTicketsSold;
cout<<"Cost of a premium ticket: $"<<endl;
cin>>premTicketCost;
cout<<"Number of premium tickets sold: "<<endl;
cin>>premTicketsSold;
cout<<"Cost of a general admission ticket: $"<<endl;
cin>>genTicketCost;
cout<<"Number of general admission tickets sold: "<<endl;
cin>>genTicketsSold;
//Step 5: Total Money for Each Type of Ticket
boxTicketsTotalMoney=boxTicketCost*boxTicketsSold;
sideTicketsTotalMoney=sideTicketCost*sideTicketsSold;
premTicketsTotalMoney=premTicketCost*premTicketsSold;
genTicketsTotalMoney=genTicketCost*genTicketsSold;
//Step 6: Total Money for All Tickets
totalMoneyMade=boxTicketsTotalMoney+sideTicketsTotalMoney+premTicketsTotalMoney+genTicketsTotalMoney;
//Step 7: Total Tickets Sold
totalTicketsSold=boxTicketsSold+sideTicketsSold+premTicketsSold+genTicketsSold;
//Step 8: Output Header
cout<<left;
cout<<setfill(' ');
cout<<setw(23)<<"Type of ticket"<<setw(15)<<"Number Sold"<<setw(11)<<"Price"<<setw(8)<<"Amount in Sales"<<endl;
//Step 9
cout<<"--------------------------------------------------------------"<<endl;
//Step 10 & 11: Output Ticket Sales
cout<<left;
cout<<"Box"<<setfill('.')<<setw(20)<<right<<"  "<<boxTicketsSold<<setw(15)<<setfill(' ')<<boxTicketCost<<right<<setw(11)<<setfill(' ')<<boxTicketsTotalMoney<<endl;
cout<<"Sideline"<<setfill('.')<<setw(15)<<right<<"  "<<sideTicketsSold<<setw(16)<<setfill(' ')<<sideTicketCost<<right<<setw(11)<<setfill(' ')<<sideTicketsTotalMoney<<endl;
cout<<"Premium"<<setfill('.')<<setw(16)<<right<<"  "<<premTicketsSold<<setw(15)<<setfill(' ')<<premTicketCost<<right<<setw(11)<<setfill(' ')<<premTicketsTotalMoney<<endl;
cout<<"General Admission"<<setfill('.')<<setw(6)<<right<<"  "<<genTicketsSold<<setw(13)<<setfill(' ' )<<genTicketCost<<setw(11)<<setfill(' ')<<genTicketsTotalMoney<<endl;
//Step 12
cout<<right;
cout<<setw(28)<<setfill(' ')<<"-----"<<setw(25)<<setfill(' ')<<"------------"<<endl;
//Step 13: Totals
cout<<right;
cout<<setw(23)<<setfill(' ')<<"Totals: "<<totalTicketsSold<<setw(19)<<setfill(' ')<<"$"<<totalMoneyMade<<endl;

return 0;

}


This is the output I get:

1
2
3
4
5
6
Type of ticket         Number Sold    Price      Amount in Sales
Box..................  5000            175     875000
Sideline.............  800             225     180000
Premium..............  4000            350   1.4e+006
General Admission....  65000           75 4.875e+006
                       -----             ------------
               Totals: 74800                  $7.33e+006


I am supposed to get this:

1
2
3
4
5
6
Type of ticket         Number Sold    Price      Amount in Sales
Box..................   5000            175     875000.00
Sideline.............    800            225     180000.00
Premium..............   4000            350    1400000.00
General Admission.... 65000             75     4875000.00
                       -----             ------------
               Totals: 74800                  $7330000.00


Any help would be appreciated.
Last edited on
You may want to play around with std::fixed and std::scientific to alter the behaviour of your dollar amount printout.
Use setprecision to increase the number significant digit.

http://www.cplusplus.com/reference/iomanip/setprecision/?kw=setprecision
Topic archived. No new replies allowed.