How to calculate or create the process calculating per hour rate

the condition given


if staff,code S
less than 8 hour-RM0.00
more than 8 hour-RM5.00 per entry
if not staff,code X
less than 8 hour-RM10.00 for first 3 hour
-RM5.00 per hour for next
between than 8 to 16 hour-RM10.00 for first 5 hour
-RM3.00 per hour for next
more than 16 hour-RM10.00

example
enter code-x
entry time-0830
exit time-1300
total hour-4 hour 30 minutes
total rate-rm17.50


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
#include <stdio.h>

void main (void)
{

	 int entime,extime,total;
	 int h,m;
	 char code,S,X;
	 float price;


	 printf("METROPOLITAN PARKING SYSTEM\n");

	 printf("Enter Code: ");
	 scanf("%c",&code);

	 printf("Enter Entry Time: ");
	 scanf("%d",&entime);

	 printf("Enter Exits Time: ");
	 scanf("%d",&extime);

	 entime = ((entime / 100) *60) + ( entime % 100);
	 extime = ((extime / 100) *60) + ( extime % 100);

	 if (extime < entime)
		 extime+=2400;

	 total = extime - entime ;

	 printf("Total in Minutes: %d minutes \n",total);


	 h = (total / 60 );
	 m = (total % 60 );

	 printf("Total Hour: %d hours %d minutes ",h,m );


        	 if (code>='S')
		 {
		  if (total<480)
				price=0.00;

		  else if (total>=480)
				price=5.00;

		  }

	 else if (code>='X')
			  {
			if (total<=480)
				 {
				 if (total=180)
					  price=10.00;

				 else if (total>180)
					  price=5.00;
				 }

			else if ((total>480)&&(total<=960))
				 {
				 if (total=300)
					  price=10.00;

				 else if (total>300)
					  price=3.00;

				 }

			else if (total>960)
					  price=10.00;

				}


	 printf("Total Rate:RM %f",price);



}




the program can run
but the answer is wrong
whereas the process calculating per hour
I don't know how to do so
Last edited on
Topic archived. No new replies allowed.