ok each part of this code works fine but i neeed it to retturn to a certian user prompt and have tried everything i know.
Code:
/* payroll program to calculate weeks pay */
#include <stdio.h>
int main() /* starts execution */
{
// hourly worker
float work_hours = 0; /* hours worked */
float rate = 0; /* pay per hour */
//Salary-Manager
float sal_pay = 0; /* pay per salary */
// commission
const double base_sal = 245.00; /* pay per base salary */
float comm = 0; /* commission earned */
float sold = 0; /* amount sold to derive commissions */
const double comm_rate = 0.15; /* set rate of commission */
// peice worker
int unit = 0; /* unit built for sale which worker is paid per */
float unit_pay = 0; /* pay per each unit */
int worker;/* unit to represent pay code for muiltiple classes of workers */
float pay = 0; /* the total pay woker will recive for week */
printf ("Thank You.\n"); // menu prompt to select workers pay code
printf ("1 Hourly\t");
printf ("2 Manager / Salary\n");
printf ("3 Commission\t");
printf ("4 Peice\n");
printf ("Or press -1 to end\n");
while (worker != -1) // start whole loop
{
scanf ("%d", &worker); // user prompt - workers pay code
// loop for hour worker
while (worker == 1) {
printf ("Enter # of hours worked for the week :\n", work_hours);
scanf ("%f", &work_hours);
printf ("Enter hourly pay rate of worker ($00.00):\n", rate);
scanf ("%f", &rate);
if (work_hours <= 40) {
pay = rate * work_hours;
}
else {
pay = rate * 40 + (rate * 1.5 * (work_hours - 40));
}
printf ("Salary is %.2f\n", pay);
} // end hourly worker loop
// loop for manager-salary
while (worker == 2) {
printf ("Please print Manager/Salary workers set pay:", sal_pay);
scanf ("%f", &sal_pay);
pay = 0;
pay = sal_pay;
printf ("Salary is %.2f\n", pay);
}// end manager-salary loop
// commission loop
while (worker == 3) {
printf ("Please enter total sales for the week:\n" , sold);
scanf ("%f" , &sold);
comm = (float) sold * (double) comm_rate;
pay = 0;
pay = (float) comm + base_sal;
printf ("Toatl pay with $245.00 salary + earnd Commissions is: $ %.2f\n" , pay);
} // end commission loop
// peice worker loop started
while (worker == 4) {
printf ("Please enter the unit the worker built for the week:\n", unit);
scanf ("%d", &unit);
printf ("Please enter the pay for unit:", unit_pay);
scanf ("%f", &unit_pay);
pay = 0;
pay = unit * (float) unit_pay;
printf ("This unit workers pay is %.2f\n", pay);
} // end peice worker loop
} // end whole loop
return (0);
} // end main
ive used break and continue at the end of each while loop and can't get it to return to the main loop where it will allow me to enter a diffrent paycode to work on located at line 38 which is the line i would like to retun once a pay is figured
Code:
printf ("Thank You.\n"); // menu prompt to select workers pay code
printf ("1 Hourly\t");
printf ("2 Manager / Salary\n");
printf ("3 Commission\t");
printf ("4 Peice\n");
printf ("Or press -1 to end\n");
while (worker != -1) // start whole loop
{
scanf ("%d", &worker); // user prompt - workers pay code
thanks,
joe