67 035
Assignments Done
99,3%
Successfully Done
In November 2018

Answer to Question #110 in Java | JSP | JSF for Tracy Bartley

Question #110
I am having a hard time with questions 6a and 6b. 6a. I have to write a class that declares a variable named minutes, which holds minutes worked on a job, and assign a value. Display the value in hours and minutes; for example, 197 minutes becomes 3 hours and 17 minutes. Be sure to use a named consant where appropriate. 6b. Write an interactive version of the Time class that accepts the minutes worked from a user. How do I do these questions? I am very confused on how to do them. Needed basic code help.
Expert's answer
You may use this code, it will help you to solve your Java task.
class Time
{
private int minutes;//holds minutes

public void setMinutes(int min){//assign a value
this.minutes = min;
}

public String toString()// returns string the value in hours and minutes
{
int hours = (int) minutes/60;
int mins = minutes - hours*60;
return hours+" hours and "+mins+" minutes";
}
}

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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions