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.
|