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

I am trying to write a program in which I allow the user to inputand initial tim

ID: 3613758 • Letter: I

Question

I am trying to write a program in which I allow the user to inputand initial time and a final time using military time. I keep onreceiving an error message that states that i need to put a ";"before the else if statements, but when i do, it still asks for it.how do i resolve this issue?
#include <iostream>
#include <cstdio>
#include <ctime>

using namespace std;
int main()
{
   int i_hour, i_min, f_hour, f_min, t_hours,t_mins;
  
   cout << "Input a start hour using the 24hour system: ";
   cin >> i_hour;
   if ((i_hour > 23) || (i_hour < 0))
   {
   cout << "error" << endl;
   return 0;
   }
  
   cout << "Input the number of minutes afterthe hour for the start:";
   cin >> i_min;
   if ((i_min > 59) || (i_min < 0))
   {
   cout << "error"<< endl;
   return 0;
   }
  
   cout << "Input a stop hour using the 24hour system: ";
   cin >> f_hour;
   if ((f_hour > 23) || (f_hour < 0))
   {
   cout << "error" << endl;
   return 0;
    }
   cout << "Input the number of minutes afterthe hour for the stop: ";
   cin >> f_min;
   if ((f_min > 59) || (f_min < 0))
   {
   cout << "error"<<endl;
   return 0;
   }

   t_hours = f_hour - i_hour;
   t_mins = f_min - i_min;
   
   else if (t_mins > 59)
   {
   t_mins = (((f_min + i_min)%60) &&(t_hours = (t_hours +1)));
   }
   else if (t_hours > 23)
   {
   t_hours = (t_hours - 24);
   }
   else
   {
   cout << "The time from start to finish is"<<t_hours<<" hours"<<t_mins<<"minutes. ";
   }
return 0;
}

Explanation / Answer

       elseif (t_mins > 59)

    {

    t_mins = (((f_min +i_min)%60) && (t_hours = (t_hours +1)));

    }

    else if (t_hours >23)

    {

    t_hours = (t_hours -24);

    }

    else

    {

    cout << "The timefrom start to finish is "<<t_hours

                             <<" hours"<<t_mins<<" minutes. ";

    }

   system("pause");

      return0;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote