All pastes #2110553 Raw Edit

Anonymous

public text v1 · immutable
#2110553 ·published 2012-02-07 02:35 UTC
rendered paste body
//Thomas Burlingame
//CSE 142
//TA: Simone Schaffer
//Description: This program calculates ACT/SAT scores for two 
//applicants based on their input and compares them.

//lets me use the scanner
import java.util.*;

public class Admit {
	
	public static void main(String[] args) {
		Scanner console = new Scanner(System.in);
		printIntro();
		double score1 = applicantScore(console, 1);
		double score2 = applicantScore(console, 2);
		System.out.println("First applicant overall score  = " + round(score1));
		System.out.println("Second applicant overall score  = " + round(score2));
		whoBetter(score1, score2);
	}
	
	//prints the text intro to describe the program to the user
	public static void printIntro(){
		System.out.println("This program compares two applicants to");
		System.out.println("determine which one seems like the stronger");
		System.out.println("applicant.  For each candidate I will need");
		System.out.println("either SAT or ACT scores plus a weighted GPA");
		System.out.println();
	}
	
	//calculates, prompts and prints out the information for the user to calculate score
	public static double applicantScore(Scanner console, int number){
		System.out.println("Information for applicant #" + number + ":");
		System.out.print("\tdo you have 1) SAT scores or 2) ACT scores? ");
		int type = console.nextInt();
		double examScore = calcExamScore(console, type);
		System.out.println("\texam score = " + round(examScore));
		double gpaScore = calcGpaScore(console);
		System.out.println("\tGPA score = " + round(gpaScore));
		System.out.println();
		double score = examScore + gpaScore;
		return score;
	}
	
	//calculates the exam score for the user based on their input
	public static double calcExamScore(Scanner console, int type){
		if (type <= 1){
			double examScore = satPrompt(console);
			return examScore;
		} else {
			double examScore = actPrompt(console);
			return examScore;
		}
	}
	
	//prompts the user for sat information if they choose 1 for sat
	public static double satPrompt(Scanner console){
		System.out.print("\tSAT math? ");
		int satMath = console.nextInt();
		System.out.print("\tSAT critical reading? ");
		int satCriticalReading = console.nextInt();
		System.out.print("\tSAT writing? ");
		int satWriting = console.nextInt();
		double examScore = 1.0;
		examScore *= calculateSat(console, satMath, satCriticalReading, satWriting, examScore);
		return examScore;
	}
	
	//calculates the user's exam score for sat information
	public static double calculateSat(Scanner console, int satMath, int satCriticalReading, 
			int satWriting, double examScore){
		double calculateSat = 1.0;
		calculateSat *= ((2.0*satMath)+satCriticalReading+satWriting)/32;
		return calculateSat;
	}
	
	//prompts the user for act information if they choose 2 for act
	public static double actPrompt(Scanner console){
		System.out.print("\tACT English? ");
		int actEnglish = console.nextInt();
		System.out.print("\tACT math? ");
		int actMath = console.nextInt();
		System.out.print("\tACT reading? ");
		int actReading = console.nextInt();
		System.out.print("\tACT science? ");
		int actScience = console.nextInt();
		double examScore = 1.0;
		examScore *= calculateAct(console, actEnglish, actMath, actReading, actScience, examScore);
		return examScore;
	}
	
	//calculates the user's exam score for act information
	public static double calculateAct(Scanner console, int actEnglish, int actMath, 
			int actReading, int actScience, double examScore){
		double calculateAct = 1.0;
		calculateAct *= ((actEnglish+(2.0*actMath)+actReading+actScience)/1.8);
		return calculateAct;
	}
	
	//rounds the output numbers so that they are easily read for the user
	public static double round(double n){
		return Math.round(n * 10.0) / 10.0;
	}
	
	//prompts and calculates the user's gpa score
	public static double calcGpaScore(Scanner console){
		System.out.print("\toverall GPA? ");
		double actualGpa = console.nextDouble();
		System.out.print("\tmax GPA? ");
		double maxGpa = console.nextDouble();
		System.out.print("\tTranscript Multiplier?");
		double transcriptMultiplier = console.nextDouble();
		double gpaScore = 1.0;
		gpaScore *= (actualGpa/maxGpa)*100*transcriptMultiplier;
		return gpaScore;
	}
	
	//tests to see which applicant is better and prints out information accordingly
	public static void whoBetter(double score1, double score2){
		if (score1 > score2) {
			System.out.println("The first applicant seems to be better");
		} else if (score1 < score2) {
			System.out.println("The second applicant seems to be better");
		} else {
			System.out.println("The two applicants seem to be equal");
		}
	}
}