Review: Long-Distance Calls

Hello, I am having trouble completing this code on Long_Distance Calls, i'll post
the code i have done so far


/*A long-distance carrier charges the following rates for the telephone calls:
______________________________________________________________________
Starting Time of Call Rate per Minute
----------------------------------------------------------------------
00:00 - 06:59 0.12
07:00 - 19:00 0.55
19:01 - 23:59 0.35
----------------------------------------------------------------------
Write a program that asks for the starting time and the number of minutes of the call,
and displays the charges. The program should ask for the time to be entered as a floating-
point number in the form HH.MM. For example, 07:00 hours will be entered as
07.00, and 16:28 hours will be entered as 16.28.
Input Validation: The program should not accept times that are greater than 23:59.
Also, no number whose last two digits are greater than 59 should be accepted. Hint:
Assuming num is a floating-point variable, the following expression will give you its
fractional part:
num - static_cast<int>(num) */
[code]#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
	double time,
		   minutes,
		   rate;

	cout << setprecision(2) << fixed;
	cout << " What is the time? " << endl;
	cout << " Enter the time in this format: HH.MM, HH is hours and \n";
	cout << " MM is minutes:   ";
	cin >> time;
	if(time < 00.00 || time > 23.59)
	{
		cout << " Please enter a time between 00.00 hours and 23.59 hours." << endl;
		system("pause");
		return 0;
	}
	//time - static_cast<int>(time);
	/*if(time > 59)
	{
		cout << " The minutes in HH.MM cannot exceed 59." << endl;
		system("pause");
		return 0;
	}		*/

	cout << "\n How many minutes was your call?  ";
	cin >> minutes;
	cout << " I will display the charges depending on when the call was made\n";
	cout << " and how many minutes the call was." << endl;
	if(time >= 00.00 && time <= 06.59)
	{
		rate = 0.12;
		cout << " The rate of the starting time of call is " << rate << "." << endl;
	}
	else if(time >= 07.00 && time <= 19.00)
	{
		rate = 0.55;
		cout << " The rate of the starting time of call is " << rate << "." << endl;
	}
	else if(time >= 19.01 && time <= 23.59)
	{
		rate = 0.35;
		cout << " The rate of the starting time of call is " << rate << "." << endl;
	}


	system("pause");
	return 0;
}


[/code]I am have a problem with the statement of not accepting the last two digits in the time to not exceed 59, please help
Last edited on
Topic archived. No new replies allowed.