Question

This is in Java, thanks! d Define two subclasses as below: 1) “Advanced Java” with an...

This is in Java, thanks!

d Define two subclasses as below: 1) “Advanced Java” with an additional field called “grades_in_class” 2) “Web Technology” with an additional field called “grades_Quizzes”. Define the required constructors and getter methods in both classes.

e Override the computeGrade() in both classes as below: 1. In Advanced Java, Fgrade= 40%* avg_exams+ 40%* avg_Assignments + 20* grades_in_class 2. In Web Technology, Fgrade= 30%* avg_exams+ 50%* avg_Assignments + 20*grades_Quizzes Note: Fgrade is a local variable in the computeGrade() method.

f Override the computeLetterGrade() as below a. Advanced Java: =60 && =70 && =80 && =90 && =60 && =75 && =85 && =95 && <=100 A

g Define a class named “Student” with PSID, and name as instance variables.

h Define a class named StudentOneSub that extends the Student class with an object of Advanced Java as an additional instance variable. Define a method displayOS() to display Final grade , and Letter Grade.

i Define a class named StudentTwoSub that extends the Student class with an object of Advanced Java and an object of Web Technology as additional instance variables. Define a method displayTS() to display Final grade , and Letter Grade in both subjects.

j Define a DemoGrades class with a main () method, create objects for both the StudentOneSub, and StudentTwoSub to display final grades and letter grades for the corresponding objects

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
=================================

// FinalGrade.java

public interface FinalGrade {
double computeFinalGrades();
}

===========================

// LetterGrade.java

public interface LetterGrade {
char computeLetterGrade();
}

==========================

// Course.java

public class Course {
   private String subjectCode;
   private double average_exams;
   private double average_assignments;
   /**
   * @param subjectCode
   * @param average_exams
   * @param average_assignments
   */
   public Course(String subjectCode, double average_exams,
           double average_assignments) {
       this.subjectCode = subjectCode;
       this.average_exams = average_exams;
       this.average_assignments = average_assignments;
   }
   /**
   * @return the subjectCode
   */
   public String getSubjectCode() {
       return subjectCode;
   }
   /**
   * @param subjectCode the subjectCode to set
   */
   public void setSubjectCode(String subjectCode) {
       this.subjectCode = subjectCode;
   }
   /**
   * @return the average_exams
   */
   public double getAverage_exams() {
       return average_exams;
   }
   /**
   * @param average_exams the average_exams to set
   */
   public void setAverage_exams(double average_exams) {
       this.average_exams = average_exams;
   }
   /**
   * @return the average_assignments
   */
   public double getAverage_assignments() {
       return average_assignments;
   }
   /**
   * @param average_assignments the average_assignments to set
   */
   public void setAverage_assignments(double average_assignments) {
       this.average_assignments = average_assignments;
   }

  
}

=================================

// Advancedjava.java

public class Advancedjava extends Course implements FinalGrade, LetterGrade {
   private double gradesin_class;

   /**
   * @param subjectCode
   * @param average_exams
   * @param average_quizzes
   * @param gradesin_class
   */
   public Advancedjava(String subjectCode, double average_exams,
           double average_quizzes, double gradesin_class) {
       super(subjectCode, average_exams, average_quizzes);
       this.gradesin_class = gradesin_class;
   }

   /**
   * @return the gradesin_class
   */
   public double getGradesin_class() {
       return gradesin_class;
   }

   /**
   * @param gradesin_class
   * the gradesin_class to set
   */
   public void setGradesin_class(double gradesin_class) {
       this.gradesin_class = gradesin_class;
   }

   @Override
   public char computeLetterGrade() {
       char letterGrade = 0;
       double fgrade = computeFinalGrades();
       if (fgrade >= 90 && fgrade <= 100) {
           letterGrade = 'A';
       } else if (fgrade >= 80 && fgrade < 90) {
           letterGrade = 'B';
       } else if (fgrade >= 70 && fgrade < 80) {
           letterGrade = 'C';
       } else if (fgrade >= 60 && fgrade < 70) {
           letterGrade = 'D';
       } else if (fgrade < 60) {
           letterGrade = 'F';
       }

       return letterGrade;

   }

   @Override
   public double computeFinalGrades() {
       double Fgrade = 0.0;

       Fgrade = .40 * getAverage_exams() + 0.40 * getAverage_assignments()
               + .20 * getGradesin_class();

       return Fgrade;

   }

}

==========================

// WebTechnology.java

public class WebTechnology extends Course implements FinalGrade,LetterGrade {
private double grade_Quizzes;

   /**
   * @param subjectCode
   * @param average_exams
   * @param average_assignments
   * @param grade_Quizzes
   */
   public WebTechnology(String subjectCode, double average_exams,
           double average_assignments, double grade_Quizzes) {
       super(subjectCode, average_exams, average_assignments);
       this.grade_Quizzes = grade_Quizzes;
   }

   /**
   * @return the grade_Quizzes
   */
   public double getGrade_Quizzes() {
       return grade_Quizzes;
   }

   /**
   * @param grade_Quizzes the grade_Quizzes to set
   */
   public void setGrade_Quizzes(double grade_Quizzes) {
       this.grade_Quizzes = grade_Quizzes;
   }

   @Override
   public char computeLetterGrade() {

       double Fgrade=0.0;
       char letterGrade = 0;
       double fgrade = computeFinalGrades();
       if (fgrade >= 95 && fgrade <= 100) {
           letterGrade = 'A';
       } else if (fgrade >= 85 && fgrade < 95) {
           letterGrade = 'B';
       } else if (fgrade >= 75 && fgrade < 85) {
           letterGrade = 'C';
       } else if (fgrade >= 60 && fgrade < 75) {
           letterGrade = 'D';
       } else if (fgrade < 60) {
           letterGrade = 'F';
       }

       return letterGrade;
   }

   @Override
   public double computeFinalGrades() {
       double Fgrade=0.30*getAverage_exams()+.50*getAverage_assignments()+0.20*grade_Quizzes;
       return Fgrade;
   }
  
  
  
}

=============================

// Student.java

public class Student {

   private String PSID;
   private String name;
   /**
   * @param pSID
   * @param name
   */
   public Student(String pSID, String name) {
  
       this.PSID = pSID;
       this.name = name;
   }
   /**
   * @return the pSID
   */
   public String getPSID() {
       return PSID;
   }
   /**
   * @param pSID the pSID to set
   */
   public void setPSID(String pSID) {
       PSID = pSID;
   }
   /**
   * @return the name
   */
   public String getName() {
       return name;
   }
   /**
   * @param name the name to set
   */
   public void setName(String name) {
       this.name = name;
   }
  
  
  

}

===============================

// StudentOneSub.java

public class StudentOneSub extends Student {
private Advancedjava adJ;

   /**
   * @param pSID
   * @param name
   * @param adJ
   */
   public StudentOneSub(String pSID, String name, Advancedjava adJ) {
       super(pSID, name);
       this.adJ = adJ;
   }
public void displayOS()
{
   System.out.println("Final Grade :"+adJ.computeFinalGrades());
   System.out.println("Letter Grade :"+adJ.computeLetterGrade());
}
}

=============================

// StudenttwoSub.java

public class StudenttwoSub extends Student {
private WebTechnology wt;

   /**
   * @param pSID
   * @param name
   * @param wt
   */
   public StudenttwoSub(String pSID, String name, WebTechnology wt) {
       super(pSID, name);
       this.wt = wt;
   }

   /**
   * @return the wt
   */
   public WebTechnology getWt() {
       return wt;
   }

   /**
   * @param wt the wt to set
   */
   public void setWt(WebTechnology wt) {
       this.wt = wt;
   }
  
public void displayTS()
{
   System.out.println("Final Grade :"+wt.computeFinalGrades());
   System.out.println("Letter Grade :"+wt.computeLetterGrade());
}
  
}

=================

// DemoGrades.java

public class DemoGrades {

   public static void main(String[] args) {
       Advancedjava adJ=new Advancedjava("S1One", 89,98,99);
StudentOneSub so=new StudentOneSub("1111","James", adJ);
WebTechnology wt=new WebTechnology("S2Two", 67, 95,77);
StudenttwoSub st=new StudenttwoSub("2222", "Williams", wt);

System.out.println("Name:"+so.getName());
System.out.println("SID:"+so.getPSID());

so.displayOS();
System.out.println("Name:"+st.getName());
System.out.println("SID:"+st.getPSID());
st.displayTS();
   }

}

=================================

output:

Name:James
SID:1111
Final Grade :94.60000000000001
Letter Grade :A
Name:Williams
SID:2222
Final Grade :83.0
Letter Grade :C

=====================Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
This is in Java, thanks! d Define two subclasses as below: 1) “Advanced Java” with an...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Implement an abstract class named Person and two subclasses named Student and Staff in Java. A person has a name, address, phone number and e-mail address. A student has a credit hour status (freshman...

    Implement an abstract class named Person and two subclasses named Student and Staff in Java. A person has a name, address, phone number and e-mail address. A student has a credit hour status (freshman, sophomore, junior, or senior). Define the possible status values using an enum. Staff has an office, salaray, and date-hired. Implement the above classes in Java. Provide Constructors for classes to initialize private variables. Getters and setters should only be provided if needed. Override the toString() method...

  • Java Programming Design a class named Person and its two subclasses named Student and Employee. A...

    Java Programming Design a class named Person and its two subclasses named Student and Employee. A person has a name, address, phone number, and email address. A student has a class status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has an office, salary, date hired. Define a class named MyDate that contains the fields year, month, and day. Override the toString method in each class to display the class name and the person's name....

  • in java Define a class named ComparableNames thats extends Person and implements comparable Define a class...

    in java Define a class named ComparableNames thats extends Person and implements comparable Define a class named ComparableNames that extends Person (defined below) and implements Comparable. Override the compare To method to compare the person on the basis of name. Write a test class to find the order of two ComparableNames. class Person String name; Person00 Person(String n) name=n: Hint: in class ComparableName, you only need a constructor with arg to initialize the data filed defined in the super class...

  • Define a class named Payment that contains an instance variable "paymentAmount" (non-static member variable) of type...

    Define a class named Payment that contains an instance variable "paymentAmount" (non-static member variable) of type double that stores the amount of the payment and appropriate accessor (getPaymentAmount() ) and mutator methods. Also create a method named paymentDetails that outputs an English sentence to describe the amount of the payment. Override toString() method to call the paymentDetails() method to print the contents of payment amount and any other details not included in paymentDetails(). Define a class named CashPayment that is...

  • Java Project In Brief... For this Java project, you will create a Java program for a...

    Java Project In Brief... For this Java project, you will create a Java program for a school. The purpose is to create a report containing one or more classrooms. For each classroom, the report will contain: I need a code that works, runs and the packages are working as well The room number of the classroom. The teacher and the subject assigned to the classroom. A list of students assigned to the classroom including their student id and final grade....

  • Please answer all the questions 2. Design two programs named BaseClass and SubClass. In BaseClass, define...

    Please answer all the questions 2. Design two programs named BaseClass and SubClass. In BaseClass, define a variable xVar (type: char, value: 65), and a method myPrint to print xVar. SubClass is a subclass of BaseClass. In SubClass, define a variable yVar (type: int, value: 16) and another variable strVar (type: String, value: "java program!"). There is also a method myPrint to print the value of yVar and strVar in SubClass, as well as an additional method printAll, in which...

  • Java Program (PLEASE PROVIDE SCREENSHOT OF THE CODE) Create a class Person which is a super...

    Java Program (PLEASE PROVIDE SCREENSHOT OF THE CODE) Create a class Person which is a super class. The class includes four private String instance variables: first name, last name, social security number, and state. Write a constructor and get methods for each instance variable. Also, add a toString method to print the details of the person. After that create a class Teacher which extends the class, Person. Add a private instance variable to store number of courses. Write a constructor...

  • PRG/421 Week One Analyze Assignment – Analyzing a Java™Program Containing Abstract and Derived Classes 1.    What is...

    PRG/421 Week One Analyze Assignment – Analyzing a Java™Program Containing Abstract and Derived Classes 1.    What is the output of the program as it is written? (Program begins on p. 2) 2. Why would a programmer choose to define a method in an abstract class (such as the Animal constructor method or the getName()method in the code example) vs. defining a method as abstract (such as the makeSound()method in the example)? /********************************************************************** *           Program:          PRG/421 Week 1 Analyze Assignment *           Purpose:         Analyze the coding for...

  • Java file Name Dog Classes and Methods Create a constructor that incorporates the type, breed, and...

    Java file Name Dog Classes and Methods Create a constructor that incorporates the type, breed, and name variables (do not include topTrick). Note: The type refers to what the breed typically does; for example, a corgi would be a “cattle herding dog.” A Shiba Inu would be a “hunting dog.” Create the setTopTrick() mutator method Dog is parent class Corgi and Driver are subclasses Complete the Corgi class: Using the UML Class diagram, declare the instance variables. Create the two...

  • Java Create four classes: 1.      An Animal class that acts as a superclass for Dog and...

    Java Create four classes: 1.      An Animal class that acts as a superclass for Dog and Bird 2.      A Bird class that is a descendant of Animal 3.      A Dog class that is a descendant of Animal 4.      A “driver” class named driver that instantiates an Animal, a Dog, and a Bird object. The Animal class has: ·        one instance variable, a private String variable named   name ·        a single constructor that takes one argument, a String, used to set...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT