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.