C++ program (IMPORTANT)

Users who are viewing this thread

NicAuf

Active Member
Messages
3,136
Reaction score
0
Tokenz
0.00z
For some reason I always get the same number for the die, and I'm having trouble with the x's in columns to show the total.

Also any code throwing would be appreciated since I'm running low on time and sanity.....lol
 
  • 57
    Replies
  • 2K
    Views
  • 0
    Participant count
    Participants list
N

NightWarrior

Guest
Well the loop part is pretty simple in this scenario...You just have to keep track of your variables.
 

NicAuf

Active Member
Messages
3,136
Reaction score
0
Tokenz
0.00z
I'm still not getting the right stuff output, I'm not sure where to go from what u gave me. I'm terribly confused and frustrated.
 
N

NightWarrior

Guest
inside the part where I said you need to be building the output...

You'll need to add some more variables to see what the roll actually was...then add a for loop to loop that many times to add the '+' or '*' or whatever it is your representing on the screen...

Do that for each player.
 
N

NightWarrior

Guest
Alright, I finished off the office worker one...I'll let you do the rest..Let me know if you need more help but it won't be until tomorrow...

void ProcessOfficeWorker()
{
string lastName;
double hoursWorked;
double hourlyRate;
double regWages;
double otWages;
double totWages;
cout << "Enter employee's last name: ";
cin >> lastName;
cout << "Enter hours worked: ";
cin >> hoursWorked;
cout << "Enter hourly rate: ";
cin >> hourlyRate;
//get salary for 40 hour work week
if (hoursWorked <= 40) {
regWages = ComputeHourlyPay(hoursWorked, hourlyRate);
}
//get salary for anything > 40
if (hoursWorked > 40) {
otWages = ComputerHourlyPay(hoursWorked - 40, hourlyRate * OVERTIME_SCALE);
}
totWages = regWages + otWages;
DisplayPay(lastName, regWages, otWages,
0, totWages);
}

double ComputerHourlyPay(double hoursWorked, double hourlyRate)
{
return hoursWorked * hourlyRate;
}
 
N

NightWarrior

Guest
Also, the assignment doesn't specify if the manufacture line dudes get OT pay for anything over 40, I'd get clarification of this.
 
N

NightWarrior

Guest
I was bored so here is ProcessManufacturingWorker():
Forgive any syntax errors its been awhile since I've done C/C++ and don't forget to get the inputs for the name, hours, and payrate.

void ProcessManufacturingWorker()
{
// This function processes a manufacturing employee. It reads the
// employee name, hours worked and pay rate, displays the production
// line menu where the user selects the product manufactured, then
// computes and displays their pay including any bonus.
// Calls: ChooseProductionLineMenu()
// ComputeHourlyPay()
// DisplayPay()

//You'll need to get the inputs for the hoursWorked and pay rate
int hoursWorked;
double hourlyRate;
string name;
////////////////////////////////
int choice = ChooseProductionLineMenu();
int numItems;
double bonus;
double regWages;
double otWages;
doublt totWages;
cout<<"How many items were made?";
cin>>numItems;

switch(choice)
{
case WAGON_LINE:
bonus = WAGON_BONUS * numItems;
break;
case SLED_LINE:
bonus = SLED_BONUS * numItems;
break;
case ROLLER_SKATE_LINE:
bonus = ROLLER_SKATE_BONUS * numItems;
break;
}
if (hoursWorked <= 40)
{
regWages = ComputeHourlyPay(hoursWorked, hourlyRate);
}
if (hoursWorked > 40)
{
otWages = ComputeHourlyPay(hoursWorked - 40, hourlyRate * OVERTIME_SCALE);
}
totWages = regWages + otWages + bonus;
DisplayPay(name, regWages, otWages, bonus, totWages);

}
 

NicAuf

Active Member
Messages
3,136
Reaction score
0
Tokenz
0.00z
Woah thanks man that really helps out alot. I have so much to do this weekend school wise, but that helps so much.
 

NicAuf

Active Member
Messages
3,136
Reaction score
0
Tokenz
0.00z
Well in the directions it says that processofficeworker function calls the displaypay and computepay function. How do you do that?
 
N

NightWarrior

Guest
Well in the directions it says that processofficeworker function calls the displaypay and computepay function. How do you do that?

Look at my code man, I am calling those functions from within processOfficeWorker. One thing you will learn is to do everything in modules. You never, I mean never have one function do all the work. You always use little helper function to do it. Also, main() should never do any processing other than to maybe have some basic if then logic to call other functions. main() should be clean and not have any "worker" code in it.
 
78,874Threads
2,185,387Messages
4,959Members
Back
Top