Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help!! 1. Write a no argument constructor for the following class below.

ID: 3583262 • Letter: P

Question

Please help!!

1. Write a no argument constructor for the following class below.

2. Write a constructor for the following class that has three arguments and assigns the passed in arguments to the data fields.

3. Write getters and setters for each of the data fields in the following order.

4. Write an instance method that converts an object’s numerical value to a letter grade. The method returns the letter as a char.

            Public Class Exam{

                                    private double score;

                                    private String testName;

                                    private int test_id;

Explanation / Answer

import java.util.Scanner;

public class Exam{
   private double score;
   private String testName;
   private int test_id;

   public Exam() {

   }

   public Exam(double score, String testName, int test_id) {
       super();
       this.score = score;
       this.testName = testName;
       this.test_id = test_id;
   }

   public double getScore() {
       return score;
   }
   public void setScore(double score) {
       this.score = score;
   }
   public String getTestName() {
       return testName;
   }
   public void setTestName(String testName) {
       this.testName = testName;
   }
   public int getTest_id() {
       return test_id;
   }
   public void setTest_id(int test_id) {
       this.test_id = test_id;
   }
   public void grade(){
       System.out.println("Enter your marks in the test");
       Scanner scan=new Scanner(System.in);
       int marks=scan.nextInt();
       if(marks<50)
           System.out.println("Grade is: U");
       else if((marks>=50) && (marks<60))
           System.out.println("Grade is: E");
       else if((marks>=60) && (marks<70))
           System.out.println("Grade is: D");
       else if((marks>=70) && (marks<80))
           System.out.println("Grade is: C");
       else if((marks>=80) && (marks<90))
           System.out.println("Grade is: B");
       else if((marks>=90) && (marks<=100))
           System.out.println("Grade is: A");
       else
           System.out.println("Invalid Input");

   }

   public static void main(String[] args) {
       Exam e=new Exam();
       e.grade();
      
  
}
}