I am stuck
Sep 29, 2013 at 6:21pm UTC
ok I am new to C++ I am taking a computational Thinking course at College and in it we are doing C++ programming. The issue I am having is that once my program goes to the housekeeping module and prompts for the name and it is entered it just stops there and does not return to the main()so it can go on to the detailloop().
Thank you,
Jacob
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
#include <string>
#include <iostream>
using namespace std;
double hours, rate=10, work_week=40, overtime=1.5, pay;
string name, quit="ZZZ" ;
void housekeeping ()
{
cout << "This program computes payroll based on\n" ;
cout << "overtime rate of " << overtime << " after " << work_week << " hours.\n" ;
cout << "Enter employee name or " << quit << " to quit: " ;
cin >> name;
return ;
}
void detailloop ()
{
cout << "Enter hours worked: " ;
cin >> hours;
if (hours > work_week)
{
pay = (work_week * rate) + (hours - work_week) * rate * overtime;
}
else
{
pay = hours * rate;
}
cout << "Pay for " << name << "is $" << pay;
cout << "Enter employee name or " << quit << "to quit." ;
cin >> name;
return ;
}
void finish ()
{
cout << "Overtime pay calculations complete." ;
system ("Pause" );
}
void main ()
{
housekeeping ();
while (name != quit);
{
detailloop ();
}
finish ();
return ;
}
Sep 29, 2013 at 6:46pm UTC
Did you enter "ZZZ" as the name?
Sep 29, 2013 at 6:47pm UTC
while (name != quit);
should be
while (name != quit)
no semicolon.
Topic archived. No new replies allowed.