In: Computer Science
What is wrong with this code and how can it be fixed?
import java.util.Scanner;
public class admissionRequirement {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner myObj = new Scanner(System.in);
System.out.println("What is your name?");
String name = myObj.nextLine();
System.out.println("What is your Reading Score?");
int reading = myObj.nextInt();
System.out.println("What is your Math Score?");
int math = myObj.nextInt();
System.out.println("What is your Writing Score?");
int writing = myObj.nextInt();
System.out.println("What is your Class Standing?");
int standing = myObj.nextInt();
System.out.println("What is your Class Size?");
int size = myObj.nextInt();
double average = ((reading + math + writing) / 3);
double quarter = (standing/size);
int percentage = (25 /100) * 100;
if (math >= 200 && math <= 800 && reading >= 200 && reading <= 800 && writing >= 200 && writing <= 800)
{
if (math >=800 || reading >=800 || writing >= 800)
{
System.out.print("You are accepted!");
}
else
{
if (math < 300 || reading < 300 || writing < 300);
{
System.out.print("You are rejected because your text scores are below 300.");
}
else
{
if(average > 650 && quarter > percentage)
{
System.out.print("You are accepted!");
}
else
{
if((math < 400 && reading < 400) || (math < 400 && writing < 400) || (reading < 400 && writing < 400) || (quarter < percentage))
{
System.out.print("You are rejected because you have two test scores below 400 or you are in the bottom quarter of your class.");
}
else
{
if ((math > 400 && reading > 400) || (math > 400 && writing > 400) || (reading > 400 && writing > 400) || (quarter < percentage))
{
System.out.print("You are on the waitlist");
}
else
{
System.out.print("You are rejected");
}
}
}
}
}
}
}
}
import java.util.Scanner;
public class admissionRequirement {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner myObj = new Scanner(System.in);
System.out.println("What is your name?");
String name = myObj.nextLine();
System.out.println("What is your Reading Score?");
int reading = myObj.nextInt();
System.out.println("What is your Math Score?");
int math = myObj.nextInt();
System.out.println("What is your Writing Score?");
int writing = myObj.nextInt();
System.out.println("What is your Class Standing?");
int standing = myObj.nextInt();
System.out.println("What is your Class Size?");
int size = myObj.nextInt();
double average = ((reading + math + writing) / 3);
double quarter = (standing / size);
int percentage = (25 / 100) * 100;
if (math >= 200 && math <= 800 && reading >= 200 && reading <= 800 && writing >= 200 && writing <= 800)
{
if (math >= 800 || reading >= 800 || writing >= 800)
{
System.out.print("You are accepted!");
}
else
{
if (math < 300 || reading < 300 || writing < 300) // simicolon is not required here;
{
System.out.print("You are rejected because your text scores are below 300.");
}
else
{
if (average > 650 && quarter > percentage)
{
System.out.print("You are accepted!");
}
else
{
if ((math < 400 && reading < 400) || (math < 400 && writing < 400)
|| (reading < 400 && writing < 400) || (quarter < percentage))
{
System.out.print(
"You are rejected because you have two test scores below 400 or you are in the bottom quarter of your class.");
}
else
{
if ((math > 400 && reading > 400) || (math > 400 && writing > 400)
|| (reading > 400 && writing > 400) || (quarter < percentage))
{
System.out.print("You are on the waitlist");
}
else
{
System.out.print("You are rejected");
}
}
}
}
}
}
}
}
Note : Please comment below if you have concerns. I am here to help you
If you like my answer please rate and help me it is very Imp for me