I am making a new question b/c i didnt specify that i was using java. ur supposed to take the inetger that the user inputs and use a for loop so it starts from 2 keeps adding until it get to the intege rinputed. for example if the user inputs 5, the program should print out 14. (2+3+4+5) how would u write that using for loop? thanks in advance.
here is what i have so far
import java.util.Scanner;
public class Basic {
public static void main(String[] args) {
// Create application frame.
BasicFrame frame = new BasicFrame();
Scanner input = new Scanner(System.in);
int x;
System.out.print("Enter a number: ");
x = input.nextInt();
for (int i = 2; i <= x; i++)
{
System.out.println(i);
}
2007-10-04
09:59:33
·
3 answers
·
asked by
sniper88gt
1
in
Computers & Internet
➔ Programming & Design