F
fitz
hey guys, i'm new to java and i'm just learning so bear with me... i
have writted the following code but this gives two errors when
compiling but i can't see anything wrong with it... can someone give me
some pointers???
//This program compares a series of user inputs and determines the
smallest integer entered.
import java.util.Scanner;//program uses class scanner
public class SmallestInteger()
{{
//procedures to find smallest integer from user inputs
public void compareNumbers()
{
Scanner Input = new Scanner (System.in);
int numberCounter;//number of data to be compared
int inputNumber1;//number entered by user for comparison
int inputNumber2;//number entered by user for comparison
int smaller;//the smallest number
//requests the user to enter an integer for comparison
System.out.printf("Please specify the number of integers for
comparison or enter -1 to exit:%d",numberCounter);
numberCounter = input.nextInt();//stores the user input as
numberCounter
//loop until sentiel value is entered
while (numberCounter!= -1)
{
//requests the user to enter a number for comparison
System.out.printf("\n\nPlease enter number for
comparison:%d",inputNumber1);
inputNumber1 = input.nextInt();//stores the input by the user as
inputNumber1
numberCounter--;//decrements the counter by one
//loops when numberCounter remains positive
for (;numberCounter=0
{
//requests the user to enter a number for comparison
System.out.printf("\n\nPlease enter next number for
comparison:%d",inputNumber2);
inputNumber2 = input.nextInt();//stores the input by the user as
inputNumber2
numberCounter--;//decrements the counter by one
//informs user about number of data left to input
System.out.prinf("\n\n%d numbers left\n\n",numberCounter);
//compares the number entries
//in case of inputNumber1 larger or equal to inputNumber2
if (inputNumber1>=inputNumber2)
{
smaller=inputNumber2;//stores inputNumber2 as smaller
}
//in case of inputNumber1 smaller than inputNumber2
else if(inputNumber1<inputNumber2)
{
smaller=inputNumber1;//stores inputNumber1 as smaller
}
//requsts the user to enter the next number for comparison
System.out.printf("\n\nPlease enter next number for
comparison:%d",inputNumber1);
inputNumber1= input.nextInt();//stores input as inputNumber1
numberCounter--;
//informs user about number of data left to input
System.out.printf("\n\n%d numbers left\n\n",numberCounter);
}
//outputs the smallest number from comparison
System.out.printf("\n\nThe smallest number is:%d",smaller);
System.out.println("\n\nThanks for your time!\n\n");
}
System.out.println("Program terminated\n\n");
}
}
}
have writted the following code but this gives two errors when
compiling but i can't see anything wrong with it... can someone give me
some pointers???
//This program compares a series of user inputs and determines the
smallest integer entered.
import java.util.Scanner;//program uses class scanner
public class SmallestInteger()
{{
//procedures to find smallest integer from user inputs
public void compareNumbers()
{
Scanner Input = new Scanner (System.in);
int numberCounter;//number of data to be compared
int inputNumber1;//number entered by user for comparison
int inputNumber2;//number entered by user for comparison
int smaller;//the smallest number
//requests the user to enter an integer for comparison
System.out.printf("Please specify the number of integers for
comparison or enter -1 to exit:%d",numberCounter);
numberCounter = input.nextInt();//stores the user input as
numberCounter
//loop until sentiel value is entered
while (numberCounter!= -1)
{
//requests the user to enter a number for comparison
System.out.printf("\n\nPlease enter number for
comparison:%d",inputNumber1);
inputNumber1 = input.nextInt();//stores the input by the user as
inputNumber1
numberCounter--;//decrements the counter by one
//loops when numberCounter remains positive
for (;numberCounter=0
{
//requests the user to enter a number for comparison
System.out.printf("\n\nPlease enter next number for
comparison:%d",inputNumber2);
inputNumber2 = input.nextInt();//stores the input by the user as
inputNumber2
numberCounter--;//decrements the counter by one
//informs user about number of data left to input
System.out.prinf("\n\n%d numbers left\n\n",numberCounter);
//compares the number entries
//in case of inputNumber1 larger or equal to inputNumber2
if (inputNumber1>=inputNumber2)
{
smaller=inputNumber2;//stores inputNumber2 as smaller
}
//in case of inputNumber1 smaller than inputNumber2
else if(inputNumber1<inputNumber2)
{
smaller=inputNumber1;//stores inputNumber1 as smaller
}
//requsts the user to enter the next number for comparison
System.out.printf("\n\nPlease enter next number for
comparison:%d",inputNumber1);
inputNumber1= input.nextInt();//stores input as inputNumber1
numberCounter--;
//informs user about number of data left to input
System.out.printf("\n\n%d numbers left\n\n",numberCounter);
}
//outputs the smallest number from comparison
System.out.printf("\n\nThe smallest number is:%d",smaller);
System.out.println("\n\nThanks for your time!\n\n");
}
System.out.println("Program terminated\n\n");
}
}
}