Write a program that accepts the score of the user in English and Maths, each score out of 100. If the average score for Maths, Science and English is 76.4%, the program should calculate the score in Science.
Solve without using if else statements
ps this is java
Answers
Answer:
okkkkkkkkkkkkkkkkkkkkkkkkk
Instead of if else the equalsto operate is used that will specify the true condition.
In this case it is the average score for Maths, Science and English is 76.4%, the science marks will be calculated.
Explanation:
import java.io.*;
public class abc
{
public static void main(String args[]) throws IOException
{
InputStreamReader read = new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(read);
System.out.print("Enter marks in English out of 100 ");
int eng = Integer.parseInt(in.readLine());
System.out.print("Enter marks in Maths out of 100 ");
int math = Integer.parseInt(in.readLine());
System.out.print("Enter marks in Science out of 100 ");
int sci = Integer.parseInt(in.readLine());
double avg = (eng + sci + math) / 3.0;
total_avg= double_avg*100;
equalsto(total_avg == 76.4)
{
sum=eng+math;
sci=double_avg-sum;
System.out.println("Eligible for Computer Science");
}
else
{
System.out.println("No score for science");
}
}
}
OUTPUT