Question
Gradable Interface Lab In JAVA jGrasp Create a new folder to save all of your work. Define two separate classes that both implement the Gradeable
Gradable Interface Lab
In JAVA jGrasp
Create a new folder to save all of your work. Define two separate classes that both implement the Gradeable interface.
public interface Gradable
{
public double getPercent();
public boolean isPassing();
}
1) The Student class will represent a student and the grade that he/she has in a class. This will be a different student class from the one you wrote in the Back To School lab so start with a blank Java file. The class will take in test scores and be able to compute the grade. A student is passing if their test average is greater than or equal to 60% Student has the following methods:
a. A constructor that takes in a String representing the name of the student
b. public void addTestScore(double score) which takes in a score that the student got on a test
c. public String getName() returns the name of the student and any other methods required by the interface
2) The DriversEd class will represent a student taking a Driving test. The DriversEd class will NOT inherit from the Student class for this lab. In this driving test the students start out with 100 points, and are deducted points when they make mistakes. If a student loses more than 15 points, then they fail.
DriversEd has the following methods:
a. A constructor that takes in a String representing the name of the person taking the test
b. public void deductPoints(int num) which will deduct points from the total
c. public String getName() returns the name of the person taking the test
3) Download the GradableRunner.java file from Blackboard to test your code.
public class GradableRunner { public static void main(String[] args) { Student John = new Student("John"); Student Paul = new Student("Paul"); DriversEd george = new DriversEd("George"); DriversEd ringo = new DriversEd("Ringo"); John.addTestScore(94.5); John.addTestScore(45); John.addTestScore(29); John.addTestScore(99); Paul.addTestScore(74); Paul.addTestScore(82); Paul.addTestScore(0); Paul.addTestScore(71); george.deductPoints(5); george.deductPoints(4); george.deductPoints(7); ringo.deductPoints(1); ringo.deductPoints(9); ringo.deductPoints(2); System.out.print(John.getName()+" has a "+John.getPercent()+" percent and "); if(John.isPassing()) System.out.println("is passing"); else System.out.println("isn't passing"); System.out.print(Paul.getName()+" has a "+Paul.getPercent()+" percent and "); if(Paul.isPassing()) System.out.println("is passing"); else System.out.println("isn't passing"); System.out.print(george.getName()+" has a "+george.getPercent()+" percent and "); if(george.isPassing()) System.out.println("is passing"); else System.out.println("isn't passing"); System.out.print(ringo.getName()+" has a "+ringo.getPercent()+" percent and "); if(ringo.isPassing()) System.out.println("is passing"); else System.out.println("isn't passing"); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started