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...
----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.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...
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]...
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();...
import java.util.Random; import java.util.Scanner; public class Compass { public Random r; public Compass(long seed){ r =...
import java.util.Random; import java.util.Scanner; public class Compass { public Random r; public Compass(long seed){ r = new Random(seed); }    public static String numberToDirection(int a){ if(a==0) return "North";    if(a==1) return "NorthEast"; if(a==2) return "East"; if(a==3) return "Southeast"; if(a==4) return "South"; if(a==5) return "Southwest"; if(a==6) return "West";    if(a==7) return "Northwest";    return "Invalid Direction" ; } public String randomDirection(){ return numberToDirection(r.nextInt()% 4 + 1); } public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter seed: ");...
import java.util.Stack; import java.util.Scanner; class Main { public static void main(String[] args)    {       ...
import java.util.Stack; import java.util.Scanner; class Main { public static void main(String[] args)    {        Stack<Integer> new_stack = new Stack<>();/* Start with the empty stack */        Scanner scan = new Scanner(System.in);        int num;        for (int i=0; i<10; i++){//Read values            num = scan.nextInt();            new_stack.push(num);        } System.out.println(""+getAvg(new_stack));    }     public static int getAvg(Stack s) {        //TODO: Find the average of the elements in the...
import java.util.Stack; import java.util.Scanner; class Main { public static void main(String[] args)    {       ...
import java.util.Stack; import java.util.Scanner; class Main { public static void main(String[] args)    {        Stack<Integer> new_stack = new Stack<>();/* Start with the empty stack */        Scanner scan = new Scanner(System.in);        int num;        for (int i=0; i<10; i++){//Read values            num = scan.nextInt();            new_stack.push(num);        }        int new_k = scan.nextInt(); System.out.println(""+smallerK(new_stack, new_k));    }     public static int smallerK(Stack s, int k) {       ...
Can someone please convert this java code to C code? import java.util.LinkedList; import java.util.List; public class...
Can someone please convert this java code to C code? import java.util.LinkedList; import java.util.List; public class Phase1 { /* Translates the MAL instruction to 1-3 TAL instructions * and returns the TAL instructions in a list * * mals: input program as a list of Instruction objects * * returns a list of TAL instructions (should be same size or longer than input list) */ public static List<Instruction> temp = new LinkedList<>(); public static List<Instruction> mal_to_tal(List<Instruction> mals) { for (int...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT