How do I get to display the variables (many of them which will have arithmetic done on them and have yet to write the code on that) at the end so the user could see all his totals?
#include <iostream>
using namespace std;
int main ()
{
int empID; // Data in which user will input info that will be have arithmetic done on it and will be displayed at the end
cout << "empID ";
cin >> empID;
C++ does not recognise If, only if.
C++ does not recognise Else, only else.
This condition is nonsensical:
(grossPay =>500<=1000)
and also => does not exist in C++, only >=
% is the modulus operator and has no place where you are putting it. You can only multiply numbers and variables together; what do you expect to happen when you try to multiply something by the % operator?
Take your cout block out of those braces ( i.e. remove the { and } that surround them).
Indent your code properly so you can see easily that you've got a problem with how many braces you have in your code. You have eight opening braces and only seven closing braces.
Thanks for the reply, I updated my code to look cleaner and once I compile / run it, it still does not display all the variables in the end...?
#include <iostream>
using namespace std;
int main ()
{
int empID; // Data in which user will input info that will be have arithmetic done on it and will be displayed at the end
cout << "empID ";
cin >> empID;
Still got the wrong number of braces, so I had to add one to make it compile; it compiled, and runs, and gives output. Take a look at where your cout statements are. With the code as above in your last post, will the cout statements always be reached?
I'm surprised you can get it to compile with a missing brace.
grossPay >=500<1000
I don't think you understand how conditions work in C++. This is almost certainly not saying what you think it is. I expect you mean this:
No, im trying to make it to where if its equal or greater than 500 but equal and less than 1000, don't know the condition for that although im learning a lot as you guys input which I really do appreciate it, fixed the brace lol and know it works but it only outputs the beginning data items but it does not output them once again after the user inputted the data and the program ran the arithmetic on it...
In the code you have above, your cout statement are part of your last else block, so they will only be reached if you enter that else block. I suspect you meant to have a closing brace after stateTax = 0;
Newly revised source code. I put the closing brace after stateTax and when I compile and run, it only outputs the beginning data such as empID, payrollType, hoursWorked, payRate, and unionCode. Yet my goal is to have the user input the variables in each data item and have the program run arithmetic to figure out some of the missing variables like federalTax and netPay which I am working on as we speak to create the code... And then in the end, to have the program display all the data info from empID to netPay... Once again, highly appreciate the help guys, I am learning a lot.
All I want is when I run the program, for it to output the beginning data such as empID, payrollType, hoursWorked, payRate, and unionCode. Then, after the user finishes inputting all the info on each slot, I'd like it to (with the help of me putting in more arithmetic codes) to display all of what is on the big section of cout in the end of my coding (empID - netPay)...
So how can I get the rest of the data items to show in the beginning so as to start displaying stateTax, federalTax, netPay, after the user inputs the information?