Question

In: Computer Science

What is wrong with this code and how can it be fixed? import java.util.Scanner; public class...

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");

}

}

}

}

}

}

}

}

Solutions

Expert Solution

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


Related Solutions

Can you fix the errors in this code? import java.util.Scanner; public class Errors6 {    public...
Can you fix the errors in this code? import java.util.Scanner; public class Errors6 {    public static void main(String[] args) {        System.out.println("This program will ask the user for three sets of two numbers and will calculate the average of each set.");        Scanner input = new Scanner(System.in);        int n1, n2;        System.out.print("Please enter the first number: ");        n1 = input.nextInt();        System.out.print("Please enter the second number: ");        n2 =...
TASK: Based upon the following code: import java.util.Scanner; // Import the Scanner class public class Main...
TASK: Based upon the following code: import java.util.Scanner; // Import the Scanner class public class Main {   public static void main( String[] args ) {     Scanner myInput = new Scanner(System.in); // Create a Scanner object     System.out.println("Enter (3) digits: ");     int W = myInput.nextInt();     int X = myInput.nextInt();     int Y = myInput.nextInt();      } } Use the tools described thus far to create additional code that will sort the integers in either monotonic ascending or descending order. Copy your code and...
whats wrong here? import java.util.Scanner; public class AirportParking2 {    public static void main(String[] args) {...
whats wrong here? import java.util.Scanner; public class AirportParking2 {    public static void main(String[] args) {        Scanner scnr = new Scanner(System.in);        int parkmins;        System.out.print("Enter minutes parked");        parkmins = scnr.nextInt();        if(parkmins < 0)            System.out.println("Invalid");        else {            if(parkmins > 30)                int numbDay = parkmins/(60*24);                parkmins -= (numbDay*24*60);                parkfee = 24 * numbDay;...
My code: import java.util.Random; import java.util.Scanner; public class RollDice { public static void main(String[] args) {...
My code: import java.util.Random; import java.util.Scanner; public class RollDice { public static void main(String[] args) { int N; Scanner keybd = new Scanner(System.in); int[] counts = new int[12];    System.out.print("Enter the number of trials: "); N = keybd.nextInt();    Random die1 = new Random(); Random die2 = new Random(); int value1, value2, sum; for(int i = 1; i <= N; i++) { value1 = die1.nextInt(6) + 1; value2 = die2.nextInt(6) + 1; sum = value1 + value2; counts[sum-1]++; }   ...
submit the following files: Main.java Consider the following code: import java.util.Scanner; public class Main { public...
submit the following files: Main.java Consider the following code: import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String input = ""; System.out.println("Enter the first number: "); input = in.nextLine(); int a = 0; int b = 0; a = Integer.parseInt(input); System.out.println("Enter the second number: "); input = in.nextLine(); b = Integer.parseInt(input); int result = 0; result = a/b; System.out.println("a/b : " + result); } Copy the code to your Main.java file...
Correct the code: import java.util.Scanner; public class Ch7_PrExercise5 { public static void main(String[] args) {   ...
Correct the code: import java.util.Scanner; public class Ch7_PrExercise5 { public static void main(String[] args) {    Scanner console = new Scanner(System.in);    double radius; double height; System.out.println("This program can calculate "+ "the area of a rectangle, the area "+ "of a circle, or volume of a cylinder."); System.out.println("To run the program enter: "); System.out.println("1: To find the area of rectangle."); System.out.println("2: To find the area of a circle."); System.out.println("3: To find the volume of a cylinder."); System.out.println("-1: To terminate the...
I need to translate my java code into C code. import java.util.Scanner; class CS_Lab3 { public...
I need to translate my java code into C code. import java.util.Scanner; class CS_Lab3 { public static void main( String args[] ) { Scanner input = new Scanner( System.in ); // create array to hold user input int nums[] = new int[10]; int i = 0, truthCount = 0; char result = 'F', result2 = 'F'; // ask user to enter integers System.out.print("Please Enter 10 Different integers: "); // gather input into array for ( i = 0; i <...
I need this Java code transform to Python Code PROGRAM: import java.util.Scanner; public class Main {...
I need this Java code transform to Python Code PROGRAM: import java.util.Scanner; public class Main { static int count=0; int calculate(int row, int column) { count++; if(row==1&&column==1) { return 0; } else if(column==1) { return ((200+calculate(row-1,column))/2); } else if(column==row) { return (200+calculate(row-1,column-1))/2; } else { return ((200+calculate(row-1,column-1))/2)+((200+calculate(row-1,column))/2); }    } public static void main(String[] args) { int row,column,weight; Main m=new Main(); System.out.println("Welcome to the Human pyramid. Select a row column combination and i will tell you how much weight the...
----fix code to search and delete a student by Identification number import java.util.Scanner; public class COurseCom666...
----fix code to search and delete a student by Identification number import java.util.Scanner; public class COurseCom666 {     private String courseName;     private String[] students = new String[1];     private int numberOfStudents;     public COurseCom666(String courseName) {         this.courseName = courseName;     }     public String[] getStudents() {         return students;     }     public int getNumberOfStudents() {         return numberOfStudents;     }     public String getCourseName() {         return courseName;     }     public int DeleteStudentsByID() {         return...
Language java Rewrite the method getMonthusing the "this" parameter CODE: import java.util.Scanner; public class DateSecondTry {...
Language java Rewrite the method getMonthusing the "this" parameter CODE: import java.util.Scanner; public class DateSecondTry { private String month; private int day; private int year; //a four digit number. public void writeOutput() { System.out.println(month + " " + day + ", " + year); } public void readInput() { Scanner keyboard = new Scanner(System.in); System.out.println("Enter month, day, and year."); System.out.println("Do not use a comma."); month = keyboard.next(); day = keyboard.nextInt(); year = keyboard.nextInt(); } public int getDay() { return day;...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT