I received no help from Cramster people on my Physics, I figured it out in the 2
ID: 3622963 • Letter: I
Question
I received no help from Cramster people on my Physics, I figured it out in the 24 hours I had the question up, I have also finished this question.
I will honor this and even Rate Life Saver if this is answered, then I can compare what I have with what you come up with, that way I make sure to submit something that works. :)
I am not getting help in the Physics assignment so I need to spend more time on that, hoping my Hero Marth or maybe someone else can help me on this, then I will have time to finish my Physics assignment.
Write a java application that accomplishes the following tasks (similar to the program assignment we did in CSC212 yet with built in exception handling):
1) Ask the number of homework assignment students have submitted in a semester
2) Calculate the letter grade the student has earned based on the average of these assignments.
Note:
1) Assume the full score for each assignment is 100. Student will get 0 for each unsubmitted assignment.
2) Student's letter grade is based on the average of all their assignments
90 -- 100 A
80 -- 89 B
70 -- 79 C
60 -- 69 D
0 -- 60 F
3) The program needs to have built in Exception handling.
Explanation / Answer
please rate - thanks
you weren't very specific and I don't have the other assignment, so hope this helps
import java.util.*;
public class except
{
public static void main(String []args)
{ Scanner in = new Scanner(System.in);
int assignments,submitted,grade=0,sum=0,i;
boolean valid;
String input;
char letter;
double average;
System.out.print("Enter number of assignments: ");
assignments=in.nextInt();
System.out.print("Enter number of assignments submitted: ");
submitted=in.nextInt();
for(i=0;i<submitted;i++)
do
{ try
{System.out.print("Enter grade: ");
input=in.next();
grade=Integer.parseInt(input);
sum+=grade;
valid=true;
}
catch (NumberFormatException nfe)
{System.out.println("Invalid Entry: ");
valid=false;
}
}while(!valid);
average=sum/(double)assignments;
switch((int)(average/10))
{case 10:
case 9: letter='A';
break;
case 8: letter='B';
break;
case 7: letter='C';
break;
case 6: letter='D';
break;
default: letter='F';
break;
}
System.out.println("Your average is "+average+" which gives you a grade of "+letter);
}
}