Creating an Exam Object using Java
Given the following Data Definition Class:
public class Exam {
private static int total;
public static void setTotal(int t) {total = t;}
private int score;
public void setScore (int s) {score = s;}
public double grade () {return 100.0 * score/total;}
}
Using four lines of code:
Create an Exam object
Enter 50 for the total possible points for the exam
Prompt the user for the student's score and put that value into an object
Output the student's grade