# What is wrong with this code?

• 05-24-2011
scorpionz
What is wrong with this code?
Hi,
I've been trying to write my first code ever..
I think I somehow managed to do it but there is a compiler error and I can't figure out what it is , it seems correct to me so you might help me correct the error.

The program suppose to ask the user for 5 numers and then it print the maximum value and the minumum value.
Here is what I wrote:
Code:

package firstA;
import java.util.Scanner ;
class FirstA {

public static void main(String[] args) {
int a, b, c, d, e, max = 0, min  = 0;
Scanner keyboard = new Scanner(System.in);

System.out.println ("Enter five numbers") ;
a = keyboard.netxtInt ();
b = keyboard.netxtInt ();
c = keyboard.netxtInt ();
d = keyboard.netxtInt ();
e = keyboard.netxtInt ();

if (a > b && a > c && a > d && a > e)
max = a ;
else if (b > a && b > c && b > d && b > e)
max = b ;
else if (d > a && d > b && d > c && d > e)
max = d ;
else if (c > a && c > b && c > d && c > e)
max = c ;
else if (d > a && d > b && d > c && d > e)
max = d ;
else if (e > a && e > b && e > c && e > d)
max = e ;
System.out.println("the maximum number is" + max);

if (a < b && a < c && a < d && a < e)
min = a ;
else if (b < a && b < c && b < d && b < e)
min = b ;
else if (d < a && d < b && d < c && d < e)
min = d ;
else if (c < a && c < b && c < d && c < e)
min = c ;
else if (d < a && d < b && d < c && d < e)
min = d ;
else if (e < a && e < b && e < c && e < d)
min = e ;

System.out.println("the minimum number is" + min);
}

}

the wrrors are in these lines
a = keyboard.netxtInt ();
b = keyboard.netxtInt ();
c = keyboard.netxtInt ();
d = keyboard.netxtInt ();
e = keyboard.netxtInt ();

PS. I know there maybe another way to do it but I want to do it this way, and please exuse the mess because I am totaly new to this forum.
• 05-24-2011
quzah
Quote:

Originally Posted by scorpionz
Hi,
I've been trying to write my first code ever..
I think I somehow managed to do it but there is a compiler error and I can't figure out what it is

So you are getting an error, but you didn't actually feel like telling us what it was?
Quote:

Originally Posted by scorpionz
it seems correct to me so you might help me correct the error.

It is generally easier to figure out what an error means if you actually include the error.

I think the error you are getting is: "This is Java, not C!"

Quzah.
• 05-24-2011
stabu
excuse the wild guess, but mnemonics can't be so bad that when asking for next int, they use the method name netxtInt()? :-D
• 05-24-2011
scorpionz
well, I have mentioned that I am totaly new to this thing , so you may take it easy on me if you please!!
you could've tell me nicely about the things I should include in the post and any other mistakes that I made instead of being arogant and trying to show me asa fool.
thx anyways.
• 05-24-2011
quzah
You made an account to post Java code on a C forum, and you wonder why you aren't getting the answer you want?

Quzah.
• 05-24-2011
stabu
use nextInt() instead of netxtInt() is what I'm saying. i.e. spelling mistake!
• 05-24-2011
scorpionz
No I don't wonder why I didn't get the answer I want.
I know I didn't get it because of people like you.

Anyways you don't know the circumtances which made me post here.

bottom line , I am sorry for my post just act like you didn't see it.
BYE
• 05-24-2011
scorpionz
stabu thank you very much for you help man , I really apriciated,
it was really a stupid mistake . I guess its because I didn't sleep until now :)
• 05-24-2011
spaghetticode
Quote:

Originally Posted by scorpionz
No I don't wonder why I didn't get the answer I want.
I know I didn't get it because of people like you.

Third post and already, it's all our fault. Wow, that's quick. You want helpful answers? Then don't act like a cry-baby because of some (obviously necessary) explicit criticism. Btw., what circumstances could possibly be the reason for posting Java questions in a C forum? Your internet provider refuses connection to every other forum on the internet?
• 05-24-2011
Salem
Quite.