Dev C++ Help!!

Write your question here.
hi guys. i need help with my dev C++ programming. i'm suppose to create a program which calculates the overtime of workers.here's the question. i really need help on this question. thank you.

A hypermarket pays its employees on work-hours basis and by category,A1-RM5,A2-RM7,M1-RM10,M2-RM15,BB-RM20. the hypermarket pays "straight-time" for the first 44 hours worked by each employee and pays "time-and-a-half" for all hours worked in excess of 44 hours for only category A1,A2,and M1. no extra pay for the other categories. the total work hours for each employee cannot exceed 60 hours per week. the program should request employee's name, identification card number, the number of hours employees' work last week and his category. your program should display all related information about the employee including employee's gross pay, overtime pay and net salary.

and here is my coding that i have tried.
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include <stdio.h>
#include <conio.h>

main ()
{
	char cat, name;
	int ic, totalhrs, Extrahrs, op, gp, np;
	char rep ='y';
	
	while (rep == 'y')
	{
	
	printf("\nNAME: ");
	scanf("%s",&name);
	
	printf("\nNIC: ");
	scanf("%d",&ic);
	
	printf("\nCATEGORY: ");
	scanf("%s",&cat);
	
	printf("\nTOTAL HOURS: ");
	scanf("%d",&totalhrs);
	
	(totalhrs >= 44 && totalhrs <= 60);
	
	 if (cat ='A')
	{
		
	 if (totalhrs < 43)
	
	printf ("INVALID OUTPUT");
			
		Extrahrs = totalhrs - 44;
		op = (Extrahrs * 5)/2;
		gp = (44 * 5);
		np = (gp + op);
		
	 
		printf("\n\n	SYARIKAT SMART STORE HYPERMARKET SDN. BHD.");
		printf("\n============================================================\n");	
		printf("\nNAME: %c",name);
		printf("\nNIC: %d",ic);
		printf("\nCATEGORY: %c",cat);
		printf("\nTOTAL HOURS: %d",totalhrs);
		printf("\nGROSS PAY: %d",gp);
		printf("\nOVERTIME PAY: %d",op);
		printf("\nNET PAY: %d",np);
	}
	else if ( cat = 'B')
	{
		Extrahrs = totalhrs - 44;
		op = (Extrahrs * 7)/2;
		gp = (44 * 7);
		np = (gp + op);
		
		printf("\n\n	SYARIKAT SMART STORE HYPERMARKET SDN. BHD.");
		printf("\n============================================================\n");	
		printf("\nNAME: %c",name);
		printf("\nNIC: %d",ic);
		printf("\nCATEGORY: %c",cat);
		printf("\nTOTAL HOURS: %d",totalhrs);
		printf("\nGROSS PAY: %d",gp);
		printf("\nOVERTIME PAY: %d",op);
		printf("\nNET PAY: %d",np);
	}
	else if (cat = 'M')
	{
		Extrahrs = totalhrs - 44;
		op = (Extrahrs * 10)/2;
		gp = (44 * 10);
		np = (gp + op);
		
		printf("\n\n	SYARIKAT SMART STORE HYPERMARKET SDN. BHD.");
		printf("\n============================================================\n");	
		printf("\nNAME: %c",name);
		printf("\nNIC: %d",ic);
		printf("\nCATEGORY: %c",cat);
		printf("\nTOTAL HOURS: %d",totalhrs);
		printf("\nGROSS PAY: %d",gp);
		printf("\nOVERTIME PAY: %d",op);
		printf("\nNET PAY: %d",np);
	}
	else if ( cat = 'N')
	{
		Extrahrs = totalhrs - 44;
		op = (Extrahrs * 15)/2;
		gp = (44* 15);
		np = gp;
		
		printf("\n\n	SYARIKAT SMART STORE HYPERMARKET SDN. BHD.");
		printf("\n============================================================\n");	
		printf("\nNAME: %c",name);
		printf("\nNIC: %d",ic);
		printf("\nCATEGORY: %c",cat);
		printf("\nTOTAL HOURS: %d",totalhrs);
		printf("\nGROSS PAY: %d",gp);
		printf("\nOVERTIME PAY: %d",op);
		printf("\nNET PAY: %d",np);
	}
	else if (cat = 'C')
	{
		/*Ehrs = thrs - 44;
		op = Ehrs*/
		gp = (44 * 20);
		np = gp;
		
		printf("\n\n	SYARIKAT SMART STORE HYPERMARKET SDN. BHD.");
		printf("\n============================================================\n");	
		printf("\nNAME: %c",name);
		printf("\nNIC: %d",ic);
		printf("\nCATEGORY: %c",cat);
		printf("\nTOTAL HOURS: %d",totalhrs);
		printf("\nGROSS PAY: %d",gp);
		printf("\nOVERTIME PAY: %d",op);
		printf("\nNET PAY: %d",np);
	}
	else 
	{
		printf ("INVALID NOT VALID!!");
	}
	printf("\n\nCONTINUE ? (Y/N): ");
	scanf("%s",&rep);
	
}
}
closed account (E0p9LyTq)
Your source compiles using Orwell's Dev-C++ 5.11 fork (C console project), so what are the problems you are having?
Last edited on
closed account (E0p9LyTq)
In your if statements you are using the assignment (=) operators, not the equality (==) operator.

if (cat ='A')
should be
if (cat =='A')

I personally "flip" the expression so the compiler will catch any typing/logic mistakes and report an error.
if ('A' == cat)

Line 25 (totalhrs >= 44 && totalhrs <= 60); has no effect.
Last edited on
well.. the calculations after category A1 is not working at all..it uses A1 calculations to calculate for others too and also the name that we enter is not showing out in the output..it ony shows the 1st letter of the name input..

NAME: jenny
NIC: 123
CATEGORY: a
TOTAL HOURS: 46

SYARIKAT SMART STORE HYPERMARKET SDN. BHD.
=========================================================

NAME: j
NIC: 123
CATEGORY: A
TOTAL HOURS: 46
GROSS PAY: 220
OVERTIME PAY: 5
NET PAY: 225

CONTINUE? <Y/N>:

tiz is how it shows in the output
closed account (E0p9LyTq)
You are defining the name variable as single char char name, not as a char array char name[].

If if you had created a char array you would be still getting a single character for the name. You are using the printf format specifier to print a single char %c.
closed account (E0p9LyTq)
If there a reason why this program has to be written in C? C++ strings are much easier to use.
Topic archived. No new replies allowed.