Computer Science, asked by niyajahamad42367, 7 months ago

4. Write a program in java to enter any three subject marks and find average and display
grade rccording to
Grade
A
B
More than equals to 90
More than equals to "0 and less than 90
More than equals to 50 and less than 10
Othervise
с
F​

Answers

Answered by Anonymous
0

Answer:

think f thi a suggestion to be honest with my name of a nice evening I am looking to buy it would have a lot to learn how you feel about a month and he will have no problem aahe to you have received the following user to you and I will get a better way of life in this thread

Answered by oraclenaren200palkoj
0

assuming that u want a solution that is faster computationally,

import java.io.*;

import java.util.*;

//don't concentrate on the FastReader class. move to the main method.

class Main{

static class FastReader{

BufferedReader br;

StringTokenizer st;

public FastReader(){

br = new BufferedReader(new InputStreamReader(System.in));

}

String next(){

while (st == null || !st.hasMoreElements()){

try{

st = new StringTokenizer(br.readLine());

}

catch (IOException e){

e.printStackTrace();

}

}

return st.nextToken();

}

int readInt(){

return Integer.parseInt(next());

}

}

public static void main(String[] args) {

FastReader scanner = new FastReader();

int num1 = Math.abs(scanner.readInt());int num2 = Math.abs(scanner.readInt());

int num3 = Math.abs(scanner.readInt());

double average = (double) (num1 + num2 + num3)/3;

if(num1<= 100&num2<=100;num3<=100){

if(average >= 90){

System.out.println("A");

}

else if(average < 90 & average >= 50){ /*more than equal to 0 not required

since abs value taken*/

//more than equal to 50 and less than 10 always returns false

System.out.println("B");

}

else {

if ((average >= 10 & average < 50)) {

System.out.println("C");

} else {

System.out.println("F");

}

}

}

else {

System.err.println("Invalid input");

}

}

}

if u find this answer helpful, please mark this as the brainliest.

if u find any of the lines confusing reach me out in the comment section

Similar questions