I am trying to write a simple program in c++ to take a beginning delivery time in 24 hour time and an ending delivery time then taking 25% off that time(making the end time 25% sooner). For example, i'd have a user enter in 0900 for start time and 1030 for an end time. The output for the new end time is 1007. My code sort of works, but I don't know how to incorporate the 25% sooner data.
Here it is:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
const int SIXTY = 60;
const int HUNDRED = 100;
double IMPROVEMENT = .25; // This is to multiply the 25% better time
//int start_time = 0;
int start_time;
cout << "Enter start time: " << endl;
cin >> start_time;
int start_hours = start_time / HUNDRED;
int start_minutes= start_time % HUNDRED;
int end_time;
cout << "Enter end time: " << endl;
cin >> end_time;
int end_hours = (end_time / HUNDRED);
int end_minutes = (end_time % HUNDRED);
int total_minutes = (end_minutes - start_minutes) * IMPROVEMENT;
int total_hours = end_hours - start_hours;
total_hours = total_hours / SIXTY;
cout.fill('0');
cout << "The new end time is: " << setw(2) << total_hours << setw(2) << total_minutes << endl;
return 0;
}
I need help to figure how to make the 'improved' time affect hours and not just minutes.