Results 1 to 7 of 7
  1. #1
    Nine0joe is offline Member
    Join Date
    May 2008
    Posts
    4
    Rep Power
    0

    Default Need help with constructing code

    i need to design and implement an application that reads an integer value and prints the sum of all even intergers between 2 and the input value, inclusive. i also want to print an error message if the input value is less than 2 and i want to promt the user accordingly.

    Any help will be greatly appreciated THANKS. =)

  2. #2
    Nine0joe is offline Member
    Join Date
    May 2008
    Posts
    4
    Rep Power
    0

    Default

    Also i need to know where to find the toolkits. This is an assignment for school and i downloaded ecplise, but cannot find toolkits so i can use keyboardreader, and this is what i have so far i dont know how to finish it
    Java Code:
    	public class Projects {
    
    	public static void main(String[] args) {
    	KeyboardReader temp = new KeyboardReader();
    
    			double V;
    			List<Double> valueList = new ArrayList<Double>(); // You can store the values in here
    
    			While (V = temp.readdouble("Enter a Value of 2 or more: ") ); {
    				if (V >2){
    					valueList.add(V); // just added the value to a list
    				} else {
    					System.out.println("Value must be of 2 or more, Please restart the program!!");
    				}
    			}
    
    }
    }

  3. #3
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    Java Code:
    int evennumbers = 0,total=0;
    int input = new java.util.Scanner(System.in).nextInt();
    
    while(evennumbers < input){
           total += (evennumbers += 2);
    }
    Try to test the code.

    You can add if statement to ensure that the user inputs 2 or more....
    You can play with JOptionPane.
    Last edited by sukatoa; 05-09-2008 at 01:46 AM.
    freedom exists in the world of ideas

  4. #4
    Nine0joe is offline Member
    Join Date
    May 2008
    Posts
    4
    Rep Power
    0

    Default

    You want me to include that into my code or do it separately? And do you know where to find the toolkits at?

  5. #5
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    Ofcourse, how will you realize if you just watch it and not by testing from it....

    And also, i like to confirm if that was what you like to implement.
    What toolkit are you looking for? What should be the use of that?

    Im not an eclipse user. But many are using eclipse here...
    freedom exists in the world of ideas

  6. #6
    Nine0joe is offline Member
    Join Date
    May 2008
    Posts
    4
    Rep Power
    0

    Default

    haha, well we use that in my school. i forgot to bring a copy of took kits on my flash drive. I need the toolkits that have the keyboard reader, math, and all that.. i dont know if you could help me with that lol

  7. #7
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    I think that toolkit is used for catching keyboard inputs.

    What about Scanner?

    That keyboard reader should be a type of class that uses either a Scanner class, byte conversion, or Streams.

    @My first reply, Do it separately and have some experiments from it....
    freedom exists in the world of ideas

Similar Threads

  1. I need help fixing my code.. or non code?
    By MrHuggykins in forum New To Java
    Replies: 1
    Last Post: 03-19-2008, 10:12 PM
  2. Pls some one to help mi wit this code
    By _nik_ in forum New To Java
    Replies: 3
    Last Post: 02-10-2008, 02:02 AM
  3. code help
    By chitwood in forum New To Java
    Replies: 0
    Last Post: 02-10-2008, 12:08 AM
  4. help with oop code
    By nhlfan in forum New To Java
    Replies: 1
    Last Post: 11-27-2007, 08:21 PM
  5. Replies: 1
    Last Post: 04-26-2007, 03:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •