I created this code in java, using the eclipse neon IDE. It runs until an there
ID: 3788391 • Letter: I
Question
I created this code in java, using the eclipse neon IDE. It runs until an there is an exception that something is found. Please post the corrected code(not as an image). This is fairly simple code. I also need to have the doubles rounded to one decimal place. Thank you. This should all be in one class, not multiple.
import java.util.Scanner;
public final class Applicant {
public static void main(String [] args) {
applicant();
//results();
}
//method for SAT applicant
public static double SAT(){
Scanner input;
input = new Scanner(System.in);
System.out.println("SAT math ?");
int m = input.nextInt();
System.out.println("SAT reading?");
int r = input.nextInt();
System.out.println("SAT writing ?");
int w = input.nextInt();
double score = ((2*m)+r+w)/32;
System.out.println("Exam Score = " + score);
System.out.print("Overall GPA ?");
double actualGpa=input.nextDouble();
System.out.print("Max GPA ?");
double maxGpa=input.nextDouble();
System.out.print("Transcript Multiplier ?");
double tsp=input.nextDouble();
double gpaScore=(actualGpa/maxGpa)*100*tsp;
System.out.println("GPA Score = "+gpaScore);
double overallscore1=(score+gpaScore);
input.close();
return overallscore1;
//System.out.println("first Applicant OverallScore = "+overallscore1);
}
//method for ACT applicant
public static double ACT(){
Scanner input;
input = new Scanner(System.in);
System.out.print("ACT English ?");
int e=input.nextInt();
System.out.print("ACT Math ?");
int m=input.nextInt();
System.out.print("ACT reading ?");
int r=input.nextInt();
System.out.print("ACT Science ?");
int s=input.nextInt();
double score =(e+(2*m)+r+s)/1.8;
System.out.println("Exam Score: "+score);
System.out.print("Overall GPA ?");
double actualGpa=input.nextDouble();
System.out.print("Max GPA ?");
double maxGpa=input.nextDouble();
System.out.print("Transcript Multiplier ?");
double tsp=input.nextDouble();
double gpaScore=(actualGpa/maxGpa*100*tsp);
System.out.println("GPA Score = "+gpaScore);
double overallscore2= (score+gpaScore);
input.close();
return overallscore2;
//System.out.println("first Applicant OverallScore = "+overallscore2);
}
//uses if statement to choose SAT or ACT method to run
public static void applicant(){
Scanner input;
input = new Scanner(System.in);
for(int i=1;i<=2;i++)
{
System.out.println("Information for applicant #"+i+":");
System.out.println("Which of the following do you have: 1) SAT scores, or 2) ACT scores ?");
int choice = input.nextInt();
if (choice == 1) {
SAT();
}
else if(choice==2)
{
ACT();
}
else
{
System.out.println("Not an option, Choose 1 or 2 only");
//just restarts back at applicant method, no info saved from prior entries
applicant();
}
}
input.close();
}
public static void results(double overallscore1, double overallscore2){
System.out.println("overallsCore of applicant 1:"+overallscore1);
System.out.println("Overallscore of applicant 2 :"+overallscore2);
if(overallscore1>overallscore2){
System.out.println("The first Applicant is better than Second Applicant");}
else if (overallscore1 System.out.println("second Applicant is better than First Applicant");}
else{
System.out.println("Both are good");
}
}
}
Explanation / Answer
import java.util.Scanner;
public final class Applicant {
public static void main(String[] args) {
applicant();
// results();
}
// method for SAT applicant
public static double SAT() {
Scanner input;
input = new Scanner(System.in);
System.out.println("SAT math ?");
int m = input.nextInt();
System.out.println("SAT reading?");
int r = input.nextInt();
System.out.println("SAT writing ?");
int w = input.nextInt();
double score = ((2 * m) + r + w) / 32;
System.out.printf("Exam Score = %.1f ", score);
System.out.print("Overall GPA ?");
double actualGpa = input.nextDouble();
System.out.print("Max GPA ?");
double maxGpa = input.nextDouble();
System.out.print("Transcript Multiplier ?");
double tsp = input.nextDouble();
double gpaScore = (double) (actualGpa / maxGpa) * 100 * tsp;
System.out.printf("GPA Score = %.1f ", gpaScore);
double overallscore1 = (score + gpaScore);
return overallscore1;
// System.out.println("first Applicant OverallScore = "+overallscore1);
}
// method for ACT applicant
public static double ACT() {
Scanner input;
input = new Scanner(System.in);
System.out.print("ACT English ?");
int e = input.nextInt();
System.out.print("ACT Math ?");
int m = input.nextInt();
System.out.print("ACT reading ?");
int r = input.nextInt();
System.out.print("ACT Science ?");
int s = input.nextInt();
double score = (double) (e + (2 * m) + r + s) / 1.8d;
System.out.printf("Exam Score: %.1f ", score);
System.out.print("Overall GPA ?");
double actualGpa = input.nextDouble();
System.out.print("Max GPA ?");
double maxGpa = input.nextDouble();
System.out.print("Transcript Multiplier ?");
double tsp = input.nextDouble();
double gpaScore = (actualGpa / maxGpa * 100 * tsp);
System.out.printf("GPA Score = %.1f ", gpaScore);
double overallscore2 = (score + gpaScore);
return overallscore2;
// System.out.println("first Applicant OverallScore = "+overallscore2);
}
// uses if statement to choose SAT or ACT method to run
public static void applicant() {
Scanner input;
input = new Scanner(System.in);
double overallscore1 = 0, overallscore2 = 0;
for (int i = 1; i <= 2;) {
System.out.println("Information for applicant #" + i + ":");
System.out
.println("Which of the following do you have: 1) SAT scores, or 2) ACT scores ?");
int choice = Integer.parseInt(input.next());
double score;
if (choice == 1) {
score = SAT();
} else if (choice == 2) {
score = ACT();
} else {
System.out.println("Not an option, Choose 1 or 2 only");
// just restarts back at applicant method, no info saved from
// prior entries
continue;
// applicant();
}
if (i == 1) {
overallscore1 = score;
} else if (i == 2) {
overallscore2 = score;
}
i++;
}
results(overallscore1, overallscore2);
input.close();
}
public static void results(double overallscore1, double overallscore2) {
System.out.printf("overallsCore of applicant 1: %.1f ", overallscore1);
System.out
.printf("Overallscore of applicant 2 : %.1f ", overallscore2);
if (overallscore1 > overallscore2) {
System.out
.println("The first Applicant is better than Second Applicant");
}
else if (overallscore1 < overallscore2) {
System.out
.println("second Applicant is better than First Applicant");
}
else {
System.out.println("Both are good");
}
}
}
OUTPUT:
Information for applicant #1:
Which of the following do you have: 1) SAT scores, or 2) ACT scores ?
1
SAT math ?
76
SAT reading?
78
SAT writing ?
87
Exam Score = 9.0
Overall GPA ?8
Max GPA ?9
Transcript Multiplier ?7
GPA Score = 622.2
Information for applicant #2:
Which of the following do you have: 1) SAT scores, or 2) ACT scores ?
2
ACT English ?56
ACT Math ?67
ACT reading ?87
ACT Science ?87
Exam Score: 202.2
Overall GPA ?8
Max GPA ?9
Transcript Multiplier ?8
GPA Score = 711.1
overallsCore of applicant 1: 631.2
Overallscore of applicant 2 : 913.3
second Applicant is better than First Applicant
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.