Jump to content

Reset variables to pass on new parameters.

- - - - -

  • Please log in to reply
5 replies to this topic

#1
BufferOverload

BufferOverload

    Newbie

  • Members
  • Pip
  • 5 posts
Guys, as mentioned in my introduction, I'm a newbie in the programming realm. I'm trying to practice what I learn, but have hit a wall writing a very simple program. I'm trying to pass on new parameters to compute a new time range without creating a new object. I am baffled at the fact that I can't seem to visualize what I'm missing in the code or doing wrong. I created a set method but it seems to not help much.

Object Class definition
...

Object Class
...


Any suggestions?

Thanks,
BO

Edited by BufferOverload, 15 February 2012 - 03:57 PM.


#2
Norm

Norm

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 327 posts
Can you explain what the problem is? What does the code do incorrectly? Show its output and explain what is wrong with it.

#3
BufferOverload

BufferOverload

    Newbie

  • Members
  • Pip
  • 5 posts
Norm,

Thanks for the suggestion; I will post the entire code in a few minutes. Let me better explain. I came across an exercise problem in my text book that asks the user to create an time calculator class that computes the amount of time that passes between a starting time and an ending time.

For example, suppose the two times are 0800 and 2100. Then the program output should look something like

Start time: 0800, end time: 2100.
Exactly 13 hours and 0 minutes have passed.

Total elapsed time in minutes: 780
Total elapsed time in hours: 13.00

Up to this point, I think I have my bases covered. The problem I'm having is passing new time values. For example, once I input 0800 and 2100 -let code do its computation- and try to input a new set of start and ending times, I either get the same values I input originally for 0800, 2100 or get zero for all output for the second set of times.

Will update the code snipped in my original post.

#4
Norm

Norm

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 327 posts
What does the program currently output? Please post its output and explain what is wrong with it.

#5
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
This can't possibly compile:
[LEFT][COLOR=#333333]TimeCalculator resetTimes(int startTimesHrs, int endTimes);[/COLOR][/LEFT]
Why is that line in the middle of the main?

#6
BufferOverload

BufferOverload

    Newbie

  • Members
  • Pip
  • 5 posts
wim DC, thanks for the pair of eyes!

Just wanted to let you guys know that I was able to find a way how to pass on new values as parameters stored in local variables and get what I was trying to accomplish. Successful debug!

Thanks for those who were willing to help.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users