Help

Why cant i use this symbol *=(multiplication and equal sign)

//2. Stadium Seating
There are three seating categories at a stadium. For a softball game, Class A seats cost
$15, Class B seats cost $12, and Class C seats cost $9. Write a program that asks how
many tickets for each class of seats were sold, then displays the amount of income generated
from ticket sales. Format your dollar amount in fixed-point notation, with two
decimal places of precision, and be sure the decimal point is always displayed.

//#include <iostream>;
#include <iomanip>;
#include <string>;
#include<cmath>;

using namespace std;

int main()
{
double classA = 15 , classB=12, classC=9;
double ticketsSold1*= classA , ticketsSold2, ticketsSold3;

cout << "How many Class A seats were sold? ";
cin >> ;
cout << "How many Class B seats were sold? ";
cin >> classB;
cout << "How many Class C seats were sold? ";
cin >> classC;

ticketsSold1

system("pause");
return(0);
}
//
closed account (SECMoG1T)
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
#include <iostream>;
#include <iomanip>;

int main()
{
  const double class_A_cost = 15 , class_B_cost=12, class_C_cost=9;
  int          ticketsSoldA,ticketsSoldB,ticketsSoldC;/// request this from user using std::cin
  double       total_Revenue{};

//double ticketsSold1*= classA , ticketsSold2, ticketsSold3; ///error: *= must have exactly two operands

std::cout << "How many Class A seats were sold? ";
std::cin >> ticketSoldA;
std::cout << "How many Class B seats were sold? ";
std::cin >> ticketSoldB;
std::cout << "How many Class C seats were sold? ";
std::cin >> ticketSoldC;

total_Revenue =(class_A_cost * ticketsSoldA) +(class_B_cost*ticketSoldB)+(class_C_cost*ticketSoldC);///dollars


//you can then Format your dollar amount in fixed-point notation, with two
//decimal places of precision, and be sure the decimal point is always displayed.

return(0);
}
Last edited on
Why cant i use this symbol *=(multiplication and equal sign)

double ticketsSold1*= classA

The *= operator means "multiply the current value of the first operand, by the value of the second operand, and assign the result to the variable used as the first operand".

How could it possibly make sense to use this in a declaration, where the first operand doesn't yet have an initial value?

Last edited on
Topic archived. No new replies allowed.