Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace DomashnoOnTimeForTheExam
- {
- class Program
- {
- static void Main(string[] args)
- {
- // get input --> int hourExam; int minuteExam; int hourArive; int minuteArive;
- int hourExam = int.Parse(Console.ReadLine());
- int minuteExam = int.Parse(Console.ReadLine());
- int hourArive = int.Parse(Console.ReadLine());
- int minuteArive = int.Parse(Console.ReadLine());
- // decide if late, on time or early
- string lateTimeEarly = "0";
- double minutesDifference = (hourExam * 60 + minuteExam) - (hourArive * 60 + minuteArive);
- if (hourExam == hourArive && minuteExam == minuteArive)
- {
- lateTimeEarly = "onTimeExactly";
- }
- else if (minutesDifference > 0 && minutesDifference <= 30)
- {
- lateTimeEarly = "onTime";
- }
- else if (minutesDifference > 30)
- {
- lateTimeEarly = "early";
- }
- else
- {
- lateTimeEarly = "late";
- }
- // set firstRowToPrint
- string firstRowToPrint = "0";
- switch (lateTimeEarly)
- {
- case "onTimeExactly":
- case "onTime":
- firstRowToPrint = "On time";
- break;
- case "early":
- firstRowToPrint = "Early";
- break;
- case "late":
- firstRowToPrint = "Late";
- break;
- }
- Console.WriteLine(firstRowToPrint);
- // if function with if <-1 if he is late and else if >1 if he is early and set print for second row
- if (minutesDifference < -1)
- {
- if (minutesDifference > -60)
- {
- double minutesToPrint = Math.Abs(minutesDifference);
- Console.WriteLine($"{minutesToPrint} minutes after the start");
- }
- else if (minutesDifference <= -60)
- {
- double hourToPrint = Math.Floor(Math.Abs(minutesDifference) / 60);
- double minutesToPrint = Math.Abs(minutesDifference) % 60;
- if (minutesToPrint >= 0 && minutesToPrint <= 9)
- {
- Console.WriteLine($"{hourToPrint}:0{minutesToPrint} hours after the start");
- }
- else
- {
- Console.WriteLine($"{hourToPrint}:{minutesToPrint} hours after the start");
- }
- }
- }
- else if (minutesDifference > 1)
- {
- if (minutesDifference < 60)
- {
- double minutesToPrint = minutesDifference;
- Console.WriteLine($"{minutesToPrint} minutes before the start");
- }
- else if (minutesDifference >= 60)
- {
- double hourToPrint = Math.Floor(minutesDifference / 60);
- double minutesToPrint = minutesDifference % 60;
- if (minutesToPrint >= 0 && minutesToPrint <= 9)
- {
- Console.WriteLine($"{hourToPrint}:0{minutesToPrint} hours before the start");
- }
- else
- {
- Console.WriteLine($"{hourToPrint}:{minutesToPrint} hours before the start");
- }
- }
- }
- // decide if he is late or early
- // calculate with how many hours and how many minutes
- // set secondRowToPrint
- // print secondRow
- }
- }
- }
Add Comment
Please, Sign In to add comment