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

Emphasis Heading 1 Heading 2 Heading 3 Heading 4 He 12 13 14 15 16 17 Define a c

ID: 3727578 • Letter: E

Question


Emphasis Heading 1 Heading 2 Heading 3 Heading 4 He 12 13 14 15 16 17 Define a class called Course with private data members code, title, credit, fee, and grade. The class has the public member functions set(string code, string title, int credit) which reads the fee and the grade, getEeco, getCredi0etrade0, print), a default constructor, and a constructor with parameters. Define a class called Person with private data members name, age, and budget. The class has the public member functions set(string name, int age) which reads the budget, get(string &, int &, int &), print(), a default constructor, and a constructor with parameters. De fine a class called Student which publicly inherits the class Person and has the private data members department, uumberCouses, tuition (the sum of all courses fee), living of type Utilities, and expenditures (sum of tuition, food, housing and books). The class has the public member functions set(string name, int age, string department, int numberotCourses), print), a default constructor, and a constructor with parameters Implement all member functions of the three classes enforcing the least privileged principle and the principle of information hiding. Use the following driver: int main Student someOne"Ali Omar", 19, "Computer Science", 5); return 0; Sample input/output Enter the budget of Ali Omar: 57880 nter information of 5 courses Enter the course code, title, credit: 1411110 IT English, 3 nter the course fee and grade: 4860 A Enter the course code, title, credit: 1411113 Programming for Engineers,3 Enter the course fee and grade: 45ee c nter the course code, title, credit: 1411116 Programming I, 4 nter the course fee and grade: 5566 B nter the course code, title, credit: 1411211 Programming II,i3 nter the course fee and grade: 4566 B er the course code, title, credit: 1411215 Java Programming. 3 nter the course fee and grade: 456e c er the cost of food, housing, and books; 350 500 3500 The person name is: Al1 Omar The person age is: 19 and budget is 57600 The student is in Computer Science department and studied 5 courses at the total cost of 35000

Explanation / Answer

Course

public class Course {

private String code;

private String title;

private int credit;

private int fee;

private Character grade;

public void set(String code,String title,int credit)

{

this.code=code;

this.title=title;

this.credit=credit;

}

public String getCode() {

return code;

}

public void setCode(String code) {

this.code = code;

}

public String getTitle() {

return title;

}

public void setTitle(String title) {

this.title = title;

}

public int getCredit() {

return credit;

}

public void setCredit(int credit) {

this.credit = credit;

}

public float getFee() {

return fee;

}

public void setFee(int fee) {

this.fee = fee;

}

public Character getGrade() {

return grade;

}

public void setGrade(Character grade) {

this.grade = grade;

}

public void print()

{

System.out.println(this.toString());

}

@Override

public String toString() {

return "Course [code=" + code + ", title=" + title + ", credit="

+ credit + ", fee=" + fee + ", grade=" + grade + "]";

}

public Course()

{

}

public Course(String code, String title, int credit, int fee,

Character grade) {

super();

this.code = code;

this.title = title;

this.credit = credit;

this.fee = fee;

this.grade = grade;

}

}

----------------------------------------------------------------------------------------------------------------------

person

public class Person {

private String name;

private int age;

private int budget;

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public int getAge() {

return age;

}

public void setAge(int age) {

this.age = age;

}

public int getBudget() {

return budget;

}

public void setBudget(int budget) {

this.budget = budget;

}

public void set(String name,int age)

{

this.name=name;

this.age=age;

}

public void print()

{

System.out.println(this.toString());

}

@Override

public String toString() {

return "Person [name=" + name + ", age=" + age + ", budget=" + budget

+ "]";

}

public Person()

{

}

public Person(String name, int age, int budget) {

super();

this.name = name;

this.age = age;

this.budget = budget;

}

}

------------------------------------------------------------------------------------------------

student

import java.util.ArrayList;

import java.util.Scanner;

public class Student extends Person{

private String department;

private int numberOfCourses;

private int tuition;

private String livingOfTypeUtilities;

private int expenditure;

public String getDepartment() {

return department;

}

public void setDepartment(String department) {

this.department = department;

}

public int getNumberOfCourses() {

return numberOfCourses;

}

public void setNumberOfCourses(int numberOfCourses) {

this.numberOfCourses = numberOfCourses;

}

public int getTuition() {

return tuition;

}

public void setTuition(int tuition) {

this.tuition = tuition;

}

public String getLivingOfTypeUtilities() {

return livingOfTypeUtilities;

}

public void setLivingOfTypeUtilities(String livingOfTypeUtilities) {

this.livingOfTypeUtilities = livingOfTypeUtilities;

}

public int getExpenditure() {

return expenditure;

}

public void setExpenditure(int expenditure) {

this.expenditure = expenditure;

}

public void print()

{

System.out.println(this.toString());

}

@Override

public String toString() {

return "Student [department=" + department + ", numberOfCourses="

+ numberOfCourses + ", tuition=" + tuition

+ ", livingOfTypeUtilities=" + livingOfTypeUtilities

+ ", expenditure=" + expenditure + "]";

}

public Student()

{

}

public Student(String department, int numberOfCourses, int tuition,

String livingOfTypeUtilities, int expenditure) {

super();

this.department = department;

this.numberOfCourses = numberOfCourses;

this.tuition = tuition;

this.livingOfTypeUtilities = livingOfTypeUtilities;

this.expenditure = expenditure;

}

public void set(String name,int age, String department,int numberOfCourses)

{

super.set(name,age);

this.department=department;

this.numberOfCourses=numberOfCourses;

}

public static void main(String args[])

{

Student someOne= new Student();

someOne.set("Ali Omar",19,"Computer Science",5);

int budget=0;

Scanner sc=new Scanner(System.in);

System.out.print("Enter the Budget of" + someOne.getName());

budget=sc.nextInt();

System.out.println("Enter Information of "+someOne.getNumberOfCourses()+"Courses");

ArrayList<Course> courses= new ArrayList<Course>();

int expenditure=0;

for(int i=1;i<=someOne.getNumberOfCourses();i++)

{

Course course=new Course();

System.out.println("Enter the Course Code, title, credit:");

String detail=sc.nextLine();

String[] entryArray = detail.split(" ");

course.set(entryArray[0],entryArray[1],Integer.parseInt(entryArray[2]));

System.out.print("Enter the Course Fee and Grade:");

String detail1=sc.next();

String[] entryArray1 = detail1.split("");

course.setFee(Integer.parseInt(entryArray1[0]));

course.setGrade(entryArray1[1].charAt(0));

courses.add(course);

expenditure+=Integer.parseInt(entryArray1[0]);

}

System.out.print("Enter the Cost of food,housing and books");

String detail2=sc.next();

String[] entryArray2 = detail2.split("");

expenditure+=Integer.parseInt(entryArray2[0])+Integer.parseInt(entryArray2[1])+Integer.parseInt(entryArray2[2]);

someOne.setExpenditure(expenditure);

someOne.print();

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote