What do you need to get on your final exam? As an instructor, I am often asked “
ID: 3753658 • Letter: W
Question
What do you need to get on your final exam?
As an instructor, I am often asked “What do I need to get on my final exam to get a ‘X’?” and the answer is usually very easy to look up based on the syllabus and your given grades. Write a program that asks the user to enter their exam scores (whole numbers), homework averages (floating point number) and the relative weights (floating point number) of two exams, the homework average, and the final exam. It then outputs the grade the student would need to receive on the final exam to get all possible grades (A, B, C, D, F)
a) (40%) You should ask for each item separately and be clear about what you are asking for using Input Dialogs (Includes reading/storing the item)
b) (20%) If a grade isn’t possible, do not produce a result (IE, if you need greater than 100 or less than 0)
c) (20%) You will additionally calculate a likely score on the final exam which is derived from the average of the two exam scores. You will calculate the likely score in the class with a letter grade.
d) (20%) Your output should use a message dialog which includes each of the required outputs (including an exam grade for every possible letter grade and the likely grade) as follows (NOTE: each part of the output is on its own like (add “ ” to make it so):
Given your test scores and homework grades, you will need to get a:
X on your exam to get an A
Y on your exam to get a B
Z on your exam to get a C
It is likely, based on past performance that you will get a U on your exam which mean you will end up with a score of T and a letter grade of B
e) Name your program: StudentQuestion.java
Explanation / Answer
// Note : I have used 80% for A,60% for B,40% for C,25% for D,otherwise F
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner;
/ Name of the class has to be "Main" only if the class is public. /
class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner reader = new Scanner(System.in); // Reading from System.in
System.out.println("Enter your exam1 score ");
int exam1 = reader.nextInt();
System.out.println("Enter your exam2 score ");
int exam2 = reader.nextInt();
System.out.println("Enter your homework averages ");
float homework = reader.nextFloat();
System.out.println("Enter weightage of exam1 ");
float w_exam1 = reader.nextFloat();
System.out.println("Enter weightage of exam2 ");
float w_exam2 = reader.nextFloat();
System.out.println("Enter weightage of homework average ");
float w_homework = reader.nextFloat();
System.out.println("Enter weightage of final exam ");
float w_finalexam = reader.nextFloat();
int final_exam=(exam1+exam2)/2;
float A=(80-(w_exam1*exam1+w_exam2*exam2+w_homework*homework))/w_finalexam;
float B=(60-(w_exam1*exam1+w_exam2*exam2+w_homework*homework))/w_finalexam;
float C=(40-(w_exam1*exam1+w_exam2*exam2+w_homework*homework))/w_finalexam;
float D=(25-(w_exam1*exam1+w_exam2*exam2+w_homework*homework))/w_finalexam;
System.out.println("Given your test scores and homework grades,you will need to get a:");
if(A>=0 && A<=100){
System.out.println(A + " on your exam to get an A ");
}
if(B>=0 && B<=100){
System.out.println(B + " on your exam to get a B ");
}
if(C>=0 && C<=100){
System.out.println(C + " on your exam to get a C");
}
if(D>=0 && D<=100){
System.out.println(D + "on your exam to get a D");
}
float final_score=w_exam1*exam1+w_exam2*exam2+w_finalexam*final_exam+w_homework*homework;
char ch;
if(final_score>=80)
{
ch='A';
}
else if(final_score>=60)
{
ch='B';
}
else if(final_score>=40)
{
ch='C';
}
else if(final_score>=25)
{
ch='D';
}
else
{
ch='F';
}
System.out.println("It is likely, based on past performance that you will get a "+ final_exam +" on your exam which mean you will end up with a score of "+final_score +" and a letter grade of "+ch);
//System.out.print(n);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.