Pat-java-5-2 then what time (15 points)

Source: Internet
Author: User

5-2 then what time (15 points)

Sometimes people use four digits to denote a time, such as 1106 for 11 points and 6 points. Now, your program calculates the end time based on the start time and elapsed time.

Reads two numbers, the first number represents the current time with such a four-digit number, the second number represents the number of minutes, the current time is calculated after so many minutes, and the result is represented as a four-digit number. When the hour is single digit, there is no leading 0, that is, 5:30 is represented as 530. Note that the second number may represent more than 60 minutes, or it may be a negative number.

Input format:

The input gives 2 integers in a row, which is the starting time of the four-digit number, and the number of minutes elapsed, separated by a space. Note: In the start time, when the hour is single digit, there is no leading 0, that is, 5:30 is represented as 530, the elapsed minutes may exceed 60, or it may be a negative number.

Output format:

Outputs a four-bit number indicating the end time. The title guarantees the start and end times within the same day.

Input Sample:
1120 110
Sample output:
1310
Import Java.util.scanner;public class main{public static void Main (string[] args) {Scanner sc = new Scanner (system.in); int time1 = Sc.nextint (); int time2 = Sc.nextint (); int mins = Time1/1000*600+time1%1000/100*60+time1%100;if (time2>=0) { mins +=time2;int hour = mins/60;int minue = mins%60;if (minue==0) {System.out.println (hour+ "" +minue+ "" +minue ");  When the hour is single digit, there is no leading 0,}//means that the minutes are 0 also to output two 0else{system.out.println (hour+ "" +minue);} Else{mins+=time2;int hour = Mins/60;int minue = mins%60;if (minue==0) {System.out.println (hour+ "" +minue+ "" +minue);} Else{system.out.println (hour+ "" +minue);}}}







Pat-java-5-2 then what time (15 points)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.