hello dear , good morning ^^
i have a problem with my code !~
coz i have a task to prepare a code for a program to find the two largest values of the 10 values entered.
what the wrong with my codePHP Code:
Scanner input = new Scanner( System.in );
int largest1 ;// largest number
int number; // user input
int counter; // number of values entered
int largest2 = 0 ;// the second largest number
System.out.println( "Enter the number 1:" );
number = input.nextInt();
largest1=number;
counter=2;
while(counter<=10){
System.out.println( "Enter the number "+counter+":" );
number = input.nextInt();
if((number>largest1))
largest2=largest1;
largest1=number;
counter++ ;
}
System.out.println("largest1 "+largest1 );
System.out.println(largest2 +"largest2");
}
}
for example ;;
if i entered for example 10 numbers
1 4 6 88 22 99 11 101 99 26
and then the output will be
largest1 = 101
largest2 = 99
help me , i'm beginner in java ^^