The Artima Developer Community
Sponsored Link

Java Answers Forum
how to use method void addValue(int x)

1 reply on 1 page. Most recent reply: Oct 2, 2002 4:12 AM by Singh M.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
J

Posts: 3
Nickname: highheat
Registered: Oct, 2002

how to use method void addValue(int x) Posted: Oct 1, 2002 6:28 PM
Reply to this message Reply
Advertisement
i have a program that inputs 4 numbers from the keyboard, i need the method void addvalue(int x) to keep track of how many numbers have been fed into the program

this is what i have

public void addValue(int x)
{
x++;
}

this does not work


Singh M.

Posts: 154
Nickname: ms
Registered: Mar, 2002

Re: how to use method void addValue(int x) Posted: Oct 2, 2002 4:12 AM
Reply to this message Reply
Create an instance variable called sum.

in the method addValue, replace x++ with sum = sum + x;

Flat View: This topic has 1 reply on 1 page
Topic: savings goal calculations Previous Topic   Next Topic Topic: encryption/security problems

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use