Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please use C++ programming! Thank you for helping:) <Time Lab> Ask the user for

ID: 3938343 • Letter: P

Question

Please use C++ programming!
Thank you for helping:)
<Time Lab> Ask the user for time hours and then minutes.
Write a "function" to convert the time to decimal hours. If minutes are > 60 be sure to increment hours. If hours are > 24, fix to 24 hour clock
Write a "function" to convert the time to minutes since 00:00.
Output: You entered "hours:minutes". Corrected, this is hours:minutes. In decimal hours this is: "hours.xx", in minutes since 00:00 this is "minutes" minutes.
For example, the user enters 26 97. Output is: You entered 26:97. Corrected, this is 3:37. In decimal hours this is 3.32 hours, in minutes since 00:00, this 217 minutes. Please use C++ programming!
Thank you for helping:)
<Time Lab> Ask the user for time hours and then minutes.
Write a "function" to convert the time to decimal hours. If minutes are > 60 be sure to increment hours. If hours are > 24, fix to 24 hour clock
Write a "function" to convert the time to minutes since 00:00.
Output: You entered "hours:minutes". Corrected, this is hours:minutes. In decimal hours this is: "hours.xx", in minutes since 00:00 this is "minutes" minutes.
For example, the user enters 26 97. Output is: You entered 26:97. Corrected, this is 3:37. In decimal hours this is 3.32 hours, in minutes since 00:00, this 217 minutes. Please use C++ programming!
Thank you for helping:)
<Time Lab> Ask the user for time hours and then minutes.
Write a "function" to convert the time to decimal hours. If minutes are > 60 be sure to increment hours. If hours are > 24, fix to 24 hour clock
Write a "function" to convert the time to minutes since 00:00.
Output: You entered "hours:minutes". Corrected, this is hours:minutes. In decimal hours this is: "hours.xx", in minutes since 00:00 this is "minutes" minutes.
For example, the user enters 26 97. Output is: You entered 26:97. Corrected, this is 3:37. In decimal hours this is 3.32 hours, in minutes since 00:00, this 217 minutes.

Explanation / Answer

#include <iostream>
#include <math.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
   int hours=0,minutes=0;
   cout << "Enter hours:Minutes --> ";
   cin >> hours >> minutes;
   int Ihours = hours,Iminutes = minutes;
   // logic for hours
   if(hours > 24 && minutes > 59){
       int hoursDifference = hours % 24;
       cout << "hoursDifference ="<<hoursDifference<<" ";
       hours =floor(hoursDifference);
       int minuteDifference = minutes % 60 ;
       minutes = floor(minuteDifference);
       hours = hours + minuteDifference / 24;
       cout << "You entered " " << Ihours << ":" << Iminutes <<" ". Corrected, this is" "<< hours << " : " <<minutes << " ". ";
   int dHours = hours * 1 ;
   double dMinutes = minutes * floor(1%60);
   cout << "In decimal hours this is: " << dHours <<" : " << (dMinutes+minutes) << " in minutes since 00:00 this is " << (hours * 60 + minutes) << " minutes .";
      
   }
   else{
      
       cout << "You entered " " << Ihours << ":" << Iminutes <<" ". Corrected, this is" "<< hours << " : " <<minutes << " ". ";
   int dHours = hours * 1 ;
   double dMinutes = minutes * floor(1%60);
   cout << "In decimal hours this is: " << dHours <<" : " << (dMinutes+minutes) << " in minutes since 00:00 this is " << (hours * 60 + minutes) << " minutes .";
      
   }
  
   return 0;
}