davedave22
10-10-2008, 07:53 PM
Hey guys, this is my first post here and i'm glad there are people out there willing to help. So here's my problem:
import java.util.*;
import java.lang.Math;
class Random
{
public static void main( String[] args)
{
int snumber;
Scanner scan = new Scanner(System.in);
System.out.print("Enter a value of n: ");
snumber = scan.nextInt();
if (snumber == 0)
{
System.out.println("Thanks for playing, and make it a great day! :)");
System.exit(0);
}
while (100 > snumber || snumber > 500)
{
System.out.println("So sorry. The value must be between 100 and 500 inclusively.");
System.out.print("Enter a value of n: ");
snumber = scan.nextInt();
if (snumber == 0)
{
System.out.println("Thanks for playing, and make it a great day! :)");
System.exit(0);
}
}
}
public void getNumber(int num)
{
System.out.print("n is " + num);
}
}
Well, this is a problem i've been having with java since i started using it this year. I'm trying to pass the variable "snumber" that the user has input into another method "getNumber". It compiles but i am not getting the print of "n is --" . Help is appreciated ;]
import java.util.*;
import java.lang.Math;
class Random
{
public static void main( String[] args)
{
int snumber;
Scanner scan = new Scanner(System.in);
System.out.print("Enter a value of n: ");
snumber = scan.nextInt();
if (snumber == 0)
{
System.out.println("Thanks for playing, and make it a great day! :)");
System.exit(0);
}
while (100 > snumber || snumber > 500)
{
System.out.println("So sorry. The value must be between 100 and 500 inclusively.");
System.out.print("Enter a value of n: ");
snumber = scan.nextInt();
if (snumber == 0)
{
System.out.println("Thanks for playing, and make it a great day! :)");
System.exit(0);
}
}
}
public void getNumber(int num)
{
System.out.print("n is " + num);
}
}
Well, this is a problem i've been having with java since i started using it this year. I'm trying to pass the variable "snumber" that the user has input into another method "getNumber". It compiles but i am not getting the print of "n is --" . Help is appreciated ;]