Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2.2.3 Method to Implement: getTimeConversion Problem. You are asked to convert a given (non-negative) integer number of seconds and convert it into its equivalent formatted

image text in transcribed

image text in transcribed

image text in transcribed

2.2.3 Method to Implement: getTimeConversion Problem. You are asked to convert a given (non-negative) integer number of seconds and convert it into its equivalent formatted in terms of days, hours, minutes, and seconds. Testing Your goal is to pass all tests related to this method in the JUnit test class TestUtilities. These tests document the expected values on various cases: study them while developing your code. However, use the console application class TimeConversionApp if you wish (e.g., use the input and expected values from the JUnit tests). Here is an example run: Enter a non-negative integer number of seconds: 10000 days 2 hours 46 minutes 40 seconds Todo. Implement the Utilities.getTimeConversion method. See the comments there for the input parameters and requirements. The String return value mist conform to the expected format (e.g., words days. hours, minutes. and seconds are always in their plural form). Of course, in the output, the maximum values that can appear for hours, minutes, and seconds are, respectively, 23. 59. and 59. 1 package console_apps; 2 30 import java.util.Scanner; 6 7 public class TimeConversionApp { 8 ge public static void main(String[] args) { 10 Scanner input new Scanner(System.in); 12 13 i Stage 1: Prompt the user for input(s) and read input(s) from the user */ System.out.println("Enter a non-negative integer number of secons:"); int seconds = input.nextInt(); /* Stage 2: Invoke the relevant utility method with the user input(s) */ String result = Utilities.getTimeConversion(seconds); 15 16 17 18 19 20 21 22 23 24 25} 26 /* Stage 3: Output the returned value back to the user over the console. */ System.out.println(result); input.close(); } I public static String getTimeConversion(int seconds) { String result = /* Your implementation of this method starts here. * Recall from Week 1's tutorial videos: * 1. No System.out.println statements should appear here. Instead, an explicit, final return statement is placed for you. 2. No Scanner operations should appear here (e.g., input.nextInt(). Instead, refer to the input parameters of this method. /* Your implementation ends here. */ return result; } }

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

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago