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.
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;
#include <iostream>;
#include <iomanip>;
int main()
{
constdouble 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);
}
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?