Okay so im new to java and I have this assignment that I started but I am now stuck :(
The instructions are:

Create an ElapsedTimeCalculator class that computes the amount of time that passes between a starting time and an ending time, in military format.

For example, suppose the two times are 1445 and 1730. Then the program output should look something like this:

Start time: 1445
End time: 1730

Exactly 2 hour(s) and 45 minute(s) have passed.

Total elapsed time in minutes: 165
Total elapsed time in hours: 2.75

ElapsedTimeCalculator Class Specifications:

1. Your class will have a constructor that takes two parameters: the starting time and the ending time in military format

2. Your class will also have these methods:

 get methods to return the starting and ending times
 a set method that resets the starting and ending times to values passed as parameters
 a method that returns the hour portion of the elapsed time
 a method that returns the minute portion of the elapsed time
 a method that returns the total elapsed time in minutes
 a method that returns the total elapsed time in hours

//a set method that resets the starting and ending times to values passed as parameters
public void setElapsedTimeCalculator()
{

}

private void reset() {

if (startTime > 0 && endTime > 0)
{
startTime = 0 ;
endTime = 0 ;
}

}

I don't have any errors so far, I am more stuck on how to begin a method that returns the hour, minute, etc.. (the third bullet). Hopefully I have done everything okay so far but if anyone can help me with that one part I would really appreciate it. Thank you!

February 12th, 2014, 11:09 AM

Norm

Re: new to programming..HELP!!

What specific questions do you have about the program?
Given the start time and end time, what does the program need to do with those numbers to get the desired values?

Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for newcomers.

February 12th, 2014, 06:47 PM

nessabenz

Beginner Java Assignment..Help!

Okay so im new to java and I have this assignment that I started but I am now stuck
The instructions are:

Create an ElapsedTimeCalculator class that computes the amount of time that passes between a starting time and an ending time, in military format.

For example, suppose the two times are 1445 and 1730. Then the program output should look something like this:

Start time: 1445
End time: 1730

Exactly 2 hour(s) and 45 minute(s) have passed.

Total elapsed time in minutes: 165
Total elapsed time in hours: 2.75

ElapsedTimeCalculator Class Specifications:

1. Your class will have a constructor that takes two parameters: the starting time and the ending time in military format

2. Your class will also have these methods:

 get methods to return the starting and ending times
 a set method that resets the starting and ending times to values passed as parameters
 a method that returns the hour portion of the elapsed time
 a method that returns the minute portion of the elapsed time
 a method that returns the total elapsed time in minutes
 a method that returns the total elapsed time in hours

I don't have any errors so far, I am more stuck on how to begin a method that returns the hour, minute, etc.. (the third bullet). Hopefully I have done everything okay so far but if anyone can help me with that part I would really appreciate it. Thank you!

February 12th, 2014, 07:02 PM

Norm

Re: new to programming..HELP!!

Given the start time and end time, what does the program need to do with those numbers to get the desired values?

February 13th, 2014, 02:34 AM

GregBrannon

Re: new to programming..HELP!!

The assignment is structured to get you thinking in small steps, so take it a step at a time. Create a method, getElapsedHours(), or a name of your choosing, and consider what must be done with the user's input to calculate and return the difference in hours between the two times. Think it through, take notes on paper or in comments in your blank method, and then code it and test it. When you think you've gotten that one right, move to the next and repeat the same steps.