help!!

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");
}
}
}
 
L

Lee Weiner

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()
{{

1. Take out the parentheses on the class declaration line:

2. You've got double braces at the beginning and end of the class. Take one
out in each place.

public class SmallestInteger
{

BTW, when you correct these two, you'll find about 6 other syntax errors.

Lee Weiner
lee AT leeweiner DOT org
 
I

IchBin

fitz said:
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
[snip code]
I have not tested but cleaned up all your compiler errors. You may want
to compare to your version. I am not testing because it is your class
assignment being done on a Sunday night.

import java.util.Scanner;
public class SmallestInteger
{
// procedures to find smallest integer from user inputs
public void compareNumbers()
{
Scanner Input = new Scanner (System.in);

int numberCounter = 0; // number of data to be compared
int inputNumber1 = 0; // number entered by user for comparison
int inputNumber2 = 0; // number entered by user for comparison
int smaller = 0; // 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
while (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.printf("\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");
}
}

--
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top