76 409
Assignments Done
Successfully Done
In May 2019

Answer to Question #12063 in C# for Jenny

Question #12063
Please help me create a program that needs in a time of the day in 24-hour notation and output it in a 12 hour notation.For example, if the input is 1343,the output should be 1:45PM, if input is 920, output should be 9:20 AM.Consider 12:00 midnight as 12:00 AM and 12:00 noon as 12:00AM.
Expert's answer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Question12063
class Program
static void Main(string[] args)
Console.Write("Enter time: ");
int time = int.Parse(Console.ReadLine());
int hours = time / 100;
int minutes = time % 100;
if(hours <= 12)
Console.WriteLine((hours % 12)+":"+minutes+"PM");

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions