The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 314 Weeks Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
I need help finishing this c++ program. I'm having trouble getting the correct times to add up together.
Â
endtime.cpp
program needs to read two integers with the following significance. The first integer value represents
a time of day on a 24 hour clock, so that 1245 represents quarter to one mid-day, for example. The second integer
represents a time duration in a similar way, so that 345 represents three hours and 45 minutes. This duration is to be
added to the first time, and the result printed out in the same notation, in this case 1630 which is the time 3 hours and
45 minutes after 12.45.
Â
Enter in a start time: 1415
Enter in a duration: 50
End time is: 1505
Â
#include <iostream>
Â
using namespace std;
int main()
{
 int startTime;
 int durationTime;
 int endTime;
 Â
 cout << "Enter in a start time: ";
 cin >> startTime;
 Â
 cout << "Enter in a duration: ";
 cin >> durationTime;
 Â
 int startHours, startMinutes, durationHours, durationMinutes;
 Â
 startHours = startTime / 100;
 startMinutes = startTime % 100;
 Â
 durationHours = durationTime / 100;
 durationMinutes = durationTime % 100;
 Â
 int endMinutes = startMinutes + durationMinutes;
 int endTimeMin = endMinutes % 60;
 int endTimeHour = endMinutes / 100;
 int endHours = startHours + durationHours;
 int THours = endHours % 24;
 Â
 endTime = THours + endTimeHour + endTimeMin;
 Â
 Â
  if(endTime >= 2400)
    {
    endTime = endTime - 2400;
    }
   Â
 cout << "End time is: " << endTime << endl;Â
 Â
}//main
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly