Error : Subscript requires array or pointer type

closed account (y6DLy60M)
So i'm assuming a variable isnt labled?
I don't know if it's the right command.
I need that command to translate everything to the right.
Help?


// Monthly Sales Tax
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
using namespace std;

int main ()
{
double year, total, sales, ctax, stax, tTax, Ctax, Stax;
char month[13];

Ctax = 0.02;
Stax = 0.06;
ctax = (total)*(Ctax);
stax = (total)*(Stax);
tTax = (stax)+(ctax);
sales = (total)-(tTax);

cout<< "What month is it ? ";
cin >> month;
cout<< "What year is it ? ";
cin>> year;
cout<< "How much was collected in total ? ";
cin >> total;

cout<< "Month: " << month << endl;
cout<< "-------------------------- \n\n";
cout<< "Total Colleced: ";
cout<< right << " $ "<< setprecision[2] << total << endl;
cout<< "Sales: ";
cout<< right << " $ "<< setprecision[2] << sales << endl;
cout<< "Count Sales Tax: ";
cout<< right << " $ " << setprecision[2] <<ctax << endl;
cout<< "State Sales Tax: ";
cout<< right << " $ " << setprecision[2] << stax << endl;
cout<< "Total Sales Tax: ";
cout<< right << " $ " << setprecision[2]<< tTax << endl;

cin.get ();
return 0;

}
These statements have no sense because variable total is uninitialized.

ctax = (total)*(Ctax);
stax = (total)*(Stax);
tTax = (stax)+(ctax);
sales = (total)-(tTax);

The expression setprecision[2] shall use parentheses.
Last edited on
closed account (y6DLy60M)
But those variables dont make sense until you input the number.. so enter all these things then ?
Last edited on
I think I said clear enough what is wrong with your program.
Last edited on
closed account (y6DLy60M)
I'm not that bright . This is the beginners section as well. How do I initialize the variable then
I did not say that variables need initialization. I said that those statements have no sense because variable total is unitialized. Do you understand what are you doing?!!!
Last edited on
closed account (y6DLy60M)
... How do you initialize total then..
One more do you understand what are you doing in these statements?!!!

Well say me what will be the value of ctax after this statement?

ctax = (total)*(Ctax);
Last edited on
closed account (y6DLy60M)
No not completely. I'm trying to figure why the other things do not make sense since I have to input total after .
closed account (y6DLy60M)
The value will be unknown because total is not enter. So does that mean I have to enter the functions using total after the input for total?
Last edited on
Topic archived. No new replies allowed.