TWO WAY STATEMENTS HW

This is a homework assignment for my class, and the professor didn't explain switch and two-way statements very well. Included is what I have so far, so please help out if you can.
1. The job classification of each employee determines the employee's hourly rate. The classifications are as follows:(I included what it's supposed to be in my program) (use a switch statement)
When an invalid Classification Type is entered, the hourly rate from classification type 1 is to be used to calculate the employee's wages and an appropriate message is to be printed after the calculated output

2. Calculate regular pay: (use a two-way if statement)
♦ When an employee works the regular number of hours:
regular_hours * hourly_rate
♦ When an employee works more than the regular number of hours: regular_hours * hourly_rate
♦ When an employee works less than the regular number of hours:
hours_worked * hourly_rate
3. Calculate overtime pay: (use a two-way if statement)
An employee is paid 1.5 times their regular hourly rate for all hours worked over the regular hours, otherwise, the overtime rate is 0.
♦ When an employee works more than the regular number of hours: (hours_worked - regular_hours) * 1.5 * hourly_rate
4. An appropriate message is to be generated for any employee who works less than 40 hours or more than 60 hours. Examples: Inadequate number of hours worked! or Excessive number of hours Worked! This message is to be printed after the calculated output. (Use one-way if statements)

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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
  //*********************** Preprocessor Directives ********************* 
#include <fstream> 
#include <iostream> 
#include <iomanip> 
#include <string> 
#include <cmath> 
#include <stdlib.h> 
 
using namespace std; 
 
//******************************* main ******************************** 
int main() 
{                                      										  
switch (job_class)															// selector variable/expression: job_class
	case 1:    5.50
	 			break;                        
	case 2:    6.00  
				 break;                      
	case 3:    7.00    
				 break;                    
	case 4:    9.00    
				 break;                    
	case 5:    12.00  
				 break; 
																			//Declaration Section 
int           hours_worked;   
			  job_class,                 
			  total_hours, 			// hours_worked - regular_hours
			  regular_hours,     	// regular_hours   *   hourly_rate                 
			  more_hours,           // regular_hours    *    hourly_rate                
			  less_hours,           // hours_worked   *    hourly_rate                             
			  overtime_hours,      // (hours_worked - regular_hours)  *  1.5  *  hourly_rate                                          
		  	  total_pay,           // regular_pay + overtime_pay     
		char  name[30],        	   // employee name (first and last)                  
 			  id_number[6];        // I.D Number                                                      
																			// input section   
			  system ("cls");      
			  cout <<  "Enter Customer Name:  ";   
			  cin >> ws;   
			  cin.getline(name,(sizeof(name)-1));   
			  cout <<  "Enter I.D. Number:  ";   
			  cin >> ws;   
			  cin.getline(id_number,(sizeof(id_number)-1));   
			  cout <<  "Enter Hours Worked:  ";   
			  cin >>  hours_worked;   
			  cout <<  "Enter the Daily Cost:  ";   
			  cin >>  job_class;   
                                                   
 																			//process section  
			  total_hours = hours_worked - 40;
			  regular_pay = regular_hours   *   hourly_rate;   
			  more_pay = regular_hours    *    hourly_rate;   
			  less_pay =  hours_worked   *    hourly_rate; 
			  overtime_pay = (hours_worked - regular_hours)  *  1.5  *  hourly_rate; 
			  total_pay = regular_pay + overtime_pay;                                                  
																			// output section   
			  system("cls");                   
			  cout << setiosflags(ios::showpoint | ios::fixed) << setprecision (2) << fixed;   
			  cout << "WorkHard Corporation"  << endl;   cout << "~~~~~~~~~~~~~~~~~~~~~~~~~"  << endl  << endl;   
			  cout << "Employee Name        " << name << endl  << endl;  
 			  cout << "I.D. Number    " << id_number << endl << endl;   
			  cout << "Job Classification       " << job_class << endl << endl;   
			  cout << "Hourly Rate   "  << switch (job_class) << endl;  
 			  cout << "Total Hours Worked  " << hours_worked << endl;   
			  cout << "Overtime Hours " << num_days << endl << endl;   
			  cout << "Regular Pay      " << regular_hours << endl;   
			  cout << "Overtime Pay        " << overtime_pay << endl;   
			  cout << "Total Earnings     " << total_pay << endl;      
			  cout << endl << endl;         //provides blank line before pause display message  
			  system("pause");  
			  return 0; 
}
In the end of http://www.cplusplus.com/doc/tutorial/control/
there are switch and if-else examples.


EDIT: Do not create multiple threads on same issue. Other thread: http://www.cplusplus.com/forum/beginner/246143/
Last edited on
Topic archived. No new replies allowed.