Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Computer Science 1- Java Please include all the code for my reference. This is my set up. PLEASE include comments for easier understanding. Paste the

Computer Science 1- Java

Please include all the code for my reference. This is my set up. PLEASE include comments for easier understanding. Paste the whole code as plain text as the answer, please. Only make changes to file "Time". PLEASE don't import anything new and keep it simple. The last time I posted this question everything was answered wrong, don't do that. I want the output of the program to be the same as the sample runs in the rubric.

public class Time { // add class variables here /* * Sets the default time to 12:00. */ public Time () { } /* * Sets hour to h and minute to m. */ public Time (int h, int m) { } /* * Returns the time as a String of length 4 in the format: 0819. */ public String toString () { } /* - Returns the time as a String converted from military time to standard time. For example, 0545 becomes 5:45 am and 1306 becomes 1:06 pm. */ public String convert() { } /* - Advances the time by one minute. Remember that 60 minutes = 1 hour. Therefore, if your time was 0359, and you add one minute, it becomes 0400. 2359 should increment to 0000. */ public void increment() { } }

------------------------------------------------------------------------------------------------------

/* * Assignment 8: Time Class * Use this runner file to test your Assignment 8 solution */ import java.io.IOException; import java.util.Scanner; class student_time_runner { public static void main(String str[]) throws IOException { Scanner scan = new Scanner(System.in); // time 1 Time t1 = new Time(14, 56); System.out.println("time1: "+ t1); System.out.println("convert time1 to standard time: "+ t1.convert()); System.out.println("time1: "+ t1); for (int i = 0; i 

---------------------------------------------------------------------------------------------

image text in transcribedimage text in transcribed

AP Computer Science Coding Assignment 8-Time Class Name Due Date: Sunday February 24 For this assignment, you will create a Time class that holds an hour value and a minute value to represent a time. Times will be stored using "military time", so 12:01 am is 0001 and 1 pm is 1300. For this assignment, you may assume valid military times range from 0000 to 2359. There will also be a method inside the Time class to display time in standard time. Valid standard times range from 12:00 am to 11:59 pm. To get started, download the template file, Time.java. Your job will be to add the constructors and methods described in the following sections to the class, Time, that is declared in this template file The Time class should include two constructors: Time() Default constructor that sets the time to 1200. Time(int h, int m) If h is between 1 and 23 inclusive, set the hour to h. Otherwise, set the hour to 0. If m is between 0 and 59 inclusive, set the minutes to m. Otherwise, set the minutes to 0 Time should also include the following methods: String toString()-Returns the time as a String of length 4 in the format: 0819. Notice that if the hour or minute is one digit, it should print a zero first. For example, 6 should print as 06 String convert()- Returns the time as a String converted from military time to standard time. For example, 0545 becomes 5:45 am and 1306 becomes 1:06 pm. void increment() Advances the time by one minute. Remember that 60 minutes 1 hour Therefore, if your time was 0359, and you add one minute, it becomes 0400. 2359 should increment to 0000 To test your code, download the runner class student _time runner.iava into the same folder that holds your Time.java. Compile and run to verify that the output matches the sample run listed on the next page I will use a similar but different runner to grade the program. In order to pass all tests, you should change student time runner.java to test different values to make sure your program fits the requirements. When you are done coding and testing, submit only your time.java file on Blackboard Assignment 8. Grading considerations, out of 50 points: Code is commented in header and above sections: 10 points Constructor methods are coded correctly: 10 points toString method works to print military time: 10 points Convert method returns correct standard time: 10 points Increment method works correctly, especially when going to next hour and past midnight: 10 points AP Computer Science Coding Assignment 8-Time Class Name Due Date: Sunday February 24 Sample Run time1: 1456 convert time1 to standard time: 2:56 pm time1: 1456 increment time1 five times: 1501 time2: 0012 increment time2 67 times: 0119 convert to time2 standard time: 1:19 am time2: 0119 time3: 0517 convert time3: 5:17 am time4: 1215 convert time4: 12:15 pm time5: 0015 convert time5: 12:15 am time6: 2359 convert time6: 11:59 pm increment time6:0000 convert time6: 12:00 am

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

2nd Edition

1597499471, 978-1597499477

More Books

Students also viewed these Databases questions

Question

1. What is our position relative to the competition?

Answered: 1 week ago

Question

need fill above income statment

Answered: 1 week ago