Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class EvenOddDigits
- {
- public static void main(String [] args){
- giveIntro();
- Scanner console = new Scanner(System.in);
- double studentOneExam = getExamScore(console);
- double studentOneGPA = getGPA(console);
- double studentTwoExam = getExamScore(console);
- double studentTwoGPA = getGPA(console);
- double studentOneTotal = total(studentOneExam, studentOneGPA);
- double studentTwoTotal = total(studentTwoExam, studentTwoGPA);
- compareApplicants(studentOneTotal, studentTwoTotal);
- }
- // Introduces the program to the user
- public static void giveIntro(){
- 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();
- }
- // Uses the console scanner to prompt for the person's statistics
- // Returns the exam scores
- public static double getExamScore(Scanner console) {
- System.out.println("Information for applicant #1:");
- System.out.print("do you have 1) SAT scores or 2) ACT scores? ");
- int choice;
- choice = console.nextInt();
- double score = 0.0;
- if (choice == 1){
- score = getSATInfo(console);
- }
- if (choice == 2){
- score = getACTInfo(console);
- }
- return score; // fix the return variable this is the problem
- }
- // Uses the console scanner to prompt for SAT information
- public static double getSATInfo(Scanner console) {
- System.out.print("SAT math? ");
- double math = console.nextInt();
- System.out.print("SAT critical reading? ");
- double reading = console.nextInt();
- System.out.print("SAT writing? ");
- double writing = console.nextInt();
- double score = SATScore(math, reading, writing);
- System.out.println("exam score = " + round(score));
- return score;
- }
- // returns the overall SAT exam score given math, reading, and writing scores
- // out of 100
- public static double SATScore (double math, double reading, double writing) {
- return (2 * math + reading + writing)/32;
- }
- // Uses the console scanner to prompt for ACT information
- public static double getACTInfo(Scanner console) {
- System.out.print("ACT English? ");
- double English = console.nextInt();
- System.out.print("ACT math? ");
- double math = console.nextInt();
- System.out.print("ACT reading? ");
- double reading = console.nextInt();
- System.out.print("ACT science? ");
- double science = console.nextInt();
- double score = ACTScore(English, math, reading, science);
- System.out.println("exam score = " + round(score));
- return score;
- }
- // returns the overall ACT exam score given English, math, reading, and
- // science scores out of 100
- public static double ACTScore (double English, double math,
- double reading, double science) {
- return (English + 2*math + reading + science)/1.8;
- }
- // Returns the overall score of the GPA given actual, max, and transcript multiplier
- // also out of 100
- public static double getGPA(Scanner console){
- System.out.print("overall GPA? ");
- double actualGPA = console.nextDouble();
- System.out.print("max GPA? ");
- double maxGPA = console.nextDouble();
- System.out.print("Transcript Multiplier? ");
- double multiplier = console.nextDouble();
- double score = GPAScore(actualGPA, maxGPA, multiplier);
- System.out.print("GPA score = " + round(score));
- System.out.println();
- return score;
- }
- public static void compareApplicants(double studentOne, double studentTwo){
- System.out.println("First applicant overall score = " +Math.round(studentOne*10.0)/10.0);
- System.out.println("Second applicant overall score = " +Math.round(studentTwo*10.0)/10.0);
- if(studentOne > studentTwo)
- System.out.print("The first applicant seems to be better");
- else
- System.out.print("The second applicant seems to be better");
- }
- // calculates the GPA score separately for the getGPA method
- public static double GPAScore (double actualGPA, double maxGPA, double multiplier){
- return (actualGPA/maxGPA)*100*multiplier;
- }
- // sounds the GPA and ACT scores to one decimal place
- public static double round(double n) {
- return Math.round(n * 10.0) / 10.0;
- }
- public static double total(double studentExam, double studentGPA){
- return studentExam + studentGPA;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement