Quick Links to Application questions (with solutions)!

C++.

Java.

Wednesday, February 17, 2010

Number - While statement (with user input) code - 2nd version

import java.util.Scanner;
class bananas
{
public static void main(String args[])
{
Scanner eggs = new Scanner(System.in);
System.out.println("Enter an interger between 1 and 100.");
int x= eggs.nextInt(), y=1, z=1;
if ( x>=1 && x<=100 )
{
while (y <= 100)
{
z = x * y;
System.out.println(z);
y++;
}
}
else
{
System.out.println("It is not an integer between 1 and 100.");
}
}
}

No comments:

Post a Comment