Java coding is not working well<
Can I input 5 real numbers and if each value is above the average, can I get B if it is less than A?
For example, 1.2 2.2 3.2 4.2 5.2 If you enter five and turn it around,
1.2 B 2.2 B 3.2 A 4.2 A 5.2 A Like this
average
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double n1 = scanner.nextDouble();
double n2 = scanner.nextDouble();
double n3 = scanner.nextDouble();
double avg = (n1 + n2 + n3) / 3;
System.out.println(n1 + " :: " + (n1 >= avg ? "A" : "B"));
System.out.println(n2 + " :: " + (n2 >= avg ? "A" : "B"));
System.out.println(n3 + " :: " + (n3 >= avg ? "A" : "B"));
}
}
© 2024 OneMinuteCode. All rights reserved.