Some programs for my class

I have been tasked with writing this program for my class for presentation of a good use of the if\else statements. However, after I input my data into the program, the only thing that is displayed is the final else statement. I don't know where the problem is in my code, Could someone look this over and tell me where the mistake is?

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
  float start_time = 00.00;
	float call_time = 0;
	float end_time = 00.00;
	float call_rate = 00.00;
	

	// Ask user to input call start time and other important information.
	cout << "Insert start and end times in the format of HH.MM for acurate displayed results.\n";
	cout << "Please insert time your call started: ";
	cin >> start_time;
	cout << "Please insert the duration of your call in minutes only: ";
	cin >> call_time;
	cout << "Please insert the time your call ended: ";
	cin >> end_time;
	cout << setprecision(2) << fixed;

	// Determine Rate of Call from input data
	if (call_time <= 07.59)
	{
		call_rate = call_time * 0.07;
		cout << "Your charge for this call is $ " << call_rate << ".";
	}
	else if (call_time <= 18.59)
	{
		call_rate = call_time * 0.12;
		cout << "Your charge for this call is $ " << call_rate << ".";
	}
	else if (call_time <= 23.59)
	{
		call_rate = call_time * 0.28;
		cout << "Your charge for this call is $ " << call_rate << ".";
	}
	else if (end_time > 23.59 && start_time <= 07.59)
	{
		call_rate = call_time * 0.07;
		cout << "Your charge for this call is $ " << call_time << " . -------- NEXT DAY.";
	}
	else if (end_time > 23.59 && start_time <= 18.59)
	{
		call_rate = call_time * 0.12;
		cout << "Your charge for this call is $ " << call_rate << " . -------- NEXT DAY.";
	}
	else if (end_time > 23.59 && start_time <= 23.59)
	{
		call_rate = call_time * 0.28;
		cout << "Your charge for this call is $ " << call_rate << " . -------- NEXT DAY";
	}
	else (start_time > 23.59);
	cout << "This is an invalid input. Please try again.";

	return 0;
Last edited on
I had forgotten to explain the basis of the problem. The problem statement that I'm tasked with is calculating different rates of a phone that is started depending on the time of day the phone call was initiated. The information is as follows:

Time of Day Rate per minute

00:00 - 07:59 0.07 per minute

08:00 - 18:59 0.12 per minute

19:00 - 23:59 0.28 per minute

I'm also asked to display a message stating "Next Day" if a call lasted longer than 23:59.
Topic archived. No new replies allowed.