Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1a. Write a method called totalHours that takes three integer arguments (number of weeks, number of days, number of hours) and returns the total integer

1a. Write a method called totalHours that takes three integer arguments (number of weeks, number of days, number of hours) and returns the total integer hours represented by the weeks, days and hours. No error checking on arguments is needed.

1b. Write a method totalDays that takes three integer arguments (number of weeks, number of days, number of hours) and returns the total real number days represented by the weeks, days and hours. No error checking on arguments is needed.

1c. Write a code segment to prompt the user to input three integers (number of weeks, number of days, number of hours) and then read the three integers from the console. Then if all three integers are non-negative, call your totalHours method and totalDays method and output the result from each. If any of the three integers input are negative, output an error message. You can assume your totalHours and totalDays methods are both in the same class as the code segment you write.

import java.util.Scanner;

Scanner in = new Scanner(System.in);

int weeks, days, hours;

System.out.println("Enter three integers, weeks, days and hours: ");

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

What Is A Database And How Do I Use It

Authors: Matt Anniss

1st Edition

1622750799, 978-1622750795

More Books

Students also viewed these Databases questions