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...
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]++; }   ...
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 <...
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...
----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...
import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class Exercise { public static void main(String[] args) {...
import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class Exercise { public static void main(String[] args) { Scanner input=new Scanner(System.in); int[] WordsCharsLetters = {0,1,2}; while(input.hasNext()) { String sentence=input.nextLine(); if(sentence!=null&&sentence.length()>0){ WordsCharsLetters[0] += calculateAndPrintChars(sentence)[0]; WordsCharsLetters[1] += calculateAndPrintChars(sentence)[1]; WordsCharsLetters[2] += calculateAndPrintChars(sentence)[2]; } else break; } input.close(); System.out.println("Words: " + WordsCharsLetters[0]); System.out.println("Characters: " + WordsCharsLetters[1]); System.out.println("Letters: " + WordsCharsLetters[2]); } static int[] calculateAndPrintChars(String sentence) { int[] WCL = new int[3]; String[] sentenceArray=sentence.split(" "); WCL[0] = sentenceArray.length; int letterCount=0; for(int i=0;i<sentence.length();i++) { if(Character.isLetter(sentence.charAt(i))) letterCount++; } WCL[1]...
import java.util.Random; import java.util.Scanner; public class Compass { // You will need to do the following:...
import java.util.Random; import java.util.Scanner; public class Compass { // You will need to do the following: // // 1.) Define a private instance variable which can // hold a reference to a Random object. // // 2.) Define a constructor which takes a seed value. // This seed will be used to initialize the // aforementioned Random instance variable. // // 3.) Define a static method named numberToDirection // which takes a direction number and returns a String // representing...
How would I prepare pseudocode and a flowchart for this? import java.util.Scanner; public class HotDogsBuns {...
How would I prepare pseudocode and a flowchart for this? import java.util.Scanner; public class HotDogsBuns {    private static int HOTDOG_COUNT_PKG = 10;    private static int BUNS_COUNT_PKG = 8;       public static void main(String[] args) {        //Scanner object to get user input        Scanner keyboard = new Scanner(System.in);               // Get number of people        System.out.print("How many people will be competing in the contest?: ");        int noOfPeople = keyboard.nextInt();...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT