View Single Post
  #3 (permalink)  
Old 05-09-2008, 02:42 AM
sukatoa's Avatar
sukatoa sukatoa is offline
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 508
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
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.
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by sukatoa : 05-09-2008 at 02:46 AM.
Reply With Quote