|
This is the first program I am writing for a C++ class I am taking. Can Anyone tell me what is wrone with it?
//A program that figures Net Pay
#include "stdafx.h"
#include<iostream>
using namespace std;
int main()
{
double hourlyWage;
double hoursWorked;
double withholdingPercentage;
cout<<"Please enter your hourly wage ";
cin>>hourlyWage;
cout<<"Please enter the number of hours worked ";
cin>>hoursWorked;
cout<<"Please enter the withholding percentage ";
cin>>withholdingPercentage;
cout<<"Your net pay is ";
cout<<hourlyWage*hoursWorked-withholdingPercentage%<<end1;
}
|
|
|
ok, so i changed the program to look like this:
//A program that figures Net Pay
#include "stdafx.h"
#include<iostream>
using namespace std;
int main()
{
double hourlyWage;
double hoursWorked;
double withholdingPercentage;
cout<<"Please enter your hourly wage ";
cin>>hourlyWage;
cout<<"Please enter the number of hours worked ";
cin>>hoursWorked;
cout<<"Please enter the withholding percentage ";
cin>>withholdingPercentage;
cout<<"Your net pay is "<<hourlyWage*hoursWorked-withholdingPercentage<<end1;
}
and it actually runs, but it says that end1 is an undeclaired identifier. I also need the withholding percentage to actually be a percentage, how do I do that? another problem is that the program goes off the screen too quickly for my to read the output.
|
|
|
First, your end1 should be endl (ENDL).
Second, you can do your math for the percent conversion in your variable call. I can't remember the number to % math right now, get back to be later if you still can't find it.
Third, the easy way to get your screen to stay open so you can see your output is to add system ("pause"); just before the return 0;
|
|
|
|
|
|
|
// |