Any C++ Programmers...

solidcrowd
10+ year member

CarAudio.com Elite
I need help fixing this program for my class HW. I'm getting problems trying to total everything up...Heres the Program. It's fine up until- cout

and cout

// This program calculates the total ticket sales after each game.

#include

#include

#include

using namespace std;

int main(int argc, char *argv[])

{

cout

double boxprice, boxsold;

double sidelineprice, sidelinesold;

double premiumprice, premiumsold;

double generalprice, generalsold;

double totalsold, totalamount;

cout

cin >> boxprice;

cout

cin >> boxsold;

cout

cin >> sidelineprice;

cout

cin >> sidelinesold;

cout

cin >> premiumprice;

cout

cin >> premiumsold;

cout

cin >> generalprice;

cout

cin >> generalsold;

cout

cout

cout

cout

system("PAUSE");

return EXIT_SUCCESS;

}

 
Code:
cout << totalsold = boxsold + sidelinesold + premiumsold + generalsold;

cout << totalamount = boxsold * boxprice + sidelinesold*sidelineprice + premiumsold *premiumprice + generalsold * generalprice;
Just as a lil FYI, you can put code segments like (code) (/code) (except with the brackets).

Onward. It doesnt work because you cant set a value on a cout statement, you can add them in the same place, but can't set the value.

Here's what you could do

Code:
cout << boxsold + sidelinesold + premiumsold + generalsold << endl; //so it goes to the next line

cout << endl << boxsold * boxprice + sidelinesold*sidelineprice + premiumsold *premiumprice + generalsold * generalprice << endl;
or

Code:
totalsold = boxsold + sidelinesold + premiumsold + generalsold;
totalamount = boxsold * boxprice + sidelinesold*sidelineprice + premiumsold *premiumprice + generalsold * generalprice;

cout << totalsold << endl << endl << totalamount;
EDIT: OOOH, read the rest of the program. cout means console out, which will only display text in the console window. You don't have to use cout to set values. So you can just get rid of the cout and it'll work.

Also, why are u getting arguments through the main? I dont recall needing arguments in C++. At the end of the program you can also just put "return 0;" instead of pausing the computer then exiting. You can also set all the double values in one line like

Code:
double boxprice, boxsold, sidelineprice, sidelinesold, premiumprice, premiumsold, generalprice, generalsold, totalsold, totalamount;
Code:
totalsold = boxsold + sidelinesold + premiumsold + generalsold;
totalamount = (boxsold * boxprice) + (sidelinesold*sidelineprice) + (premiumsold *premiumprice) + (generalsold * generalprice);
 
Activity
No one is currently typing a reply...

About this thread

solidcrowd

10+ year member
CarAudio.com Elite
Thread starter
solidcrowd
Joined
Location
Buffalo, New York
Start date
Participants
Who Replied
Replies
1
Views
150
Last reply date
Last reply from
FurbiesAndBeans
IMG_20260516_193114554_HDR.jpg

sherbanater

    May 16, 2026
  • 0
  • 0
IMG_20260516_192955471_HDR.jpg

sherbanater

    May 16, 2026
  • 0
  • 0

New threads

Top