/* 1. True, False, False (but it does fail to run), False, True, False (that first comma won't be there) */ /* 2. System.out.printf("The number e such that ln(e^1)=1 is approximately %.3f",y); System.out.printf("Many use the fraction 22 over 7 as an approximation for pi, /n"); System.out.printf("since it's approximately %.2f",x); System.out.printf("The area of a circle of radius %d is approximately %.5f * %d * %d",z,x,z,z); double sum = x+y; double prod = x*y; System.out.printf("It is not known whether pi + e is rational nor whether pi*e is /n"); System.out.printf("rational. These numbers are approximately %.2f and %.2f",sum,prod); System.out.printf("If you put $%d in the bank and it earns interest of 100%%/ n /n",w); System.out.printf("in each of n compounding intervals then the value at year's end /n"); System.out.printf("will be $1.00x(1 + 1 %/ n)^n and the limit is %.5f...", y); System.out.printf("Dollars: $%-,10.2f", k); import java.util.Scanner; public class computeGrade { public static void main(String[] args) { final double QUIZ_RATE = .1; final double FINAL_RATE = .1; final double HOMEWORK_RATE = .1; final double EXAM_RATE = .1; Scanner s = new Scanner(System.in); System.out.print("Enter your name: "); String name = s.nextLine(); System.out.print("Enter your course: "); String course = s.nextLine(); System.out.print("Enter your quiz grade: "); String input = s.nextLine(); double quizGrade = Double.parseDouble(input); System.out.print("Enter number of times marked absent: "); input = s.nextLine(); int attendance = Integer.parseInt(input); System.out.print("Enter your homework grade: "); input = s.nextLine(); double homeworkGrade = Double.parseDouble(input); System.out.print("Enter your exam grade: "); input = s.nextLine(); double examGrade = Double.parseDouble(input); System.out.print("Enter your final project grade: "); input = s.nextLine(); double finalGrade = Double.parseDouble(input); // This matches how the syllabus says to compute the final grade. double computedGrade = quizGrade * QUIZ_RATE + homeworkGrade * HOMEWORK_RATE + examGrade * EXAM_RATE + finalGrade * FINAL_RATE; double cGrade = computedGrade; // This will be used to factor in attendance if (attendance > 5) cGrade = cGrade - 10; // Cheap way to reduce letter grade by one char equivalentGrade = ' '; if (cGrade >= 90) equivalentGrade = 'A'; else if (cGrade >= 80) equivalentGrade = 'B'; else if (cGrade >= 70) equivalentGrade = 'C'; else if (cGrade >= 60) equivalentGrade = 'D'; else equivalentGrade = 'F'; if (attendance > 8) equivalentGrade = 'F'; System.out.printf("Name: " + name + ". Course: " + course + "\n"); System.out.printf("Quiz Grade: %44.2f \n", quizGrade); System.out.printf("Number of times marked absent: %25d \n", attendance); System.out.printf("Homework Grade: %40.2f \n", homeworkGrade); System.out.printf("Exam Grade: %44.2f \n", examGrade); System.out.printf("Final Project Grade: %35.2f \n", finalGrade); System.out.printf("Computed Grade (not factoring in attendance): %10.2f \n", computedGrade); System.out.println("Actual Grade: " + equivalentGrade); if(equivalentGrade != 'F') System.out.println("Congratulations, you passed!"); else System.out.println("Sorry, you failed"); } }