in java
• Create an interface called Person. In this interface create a method called printData()
• Implement interface Person by classes Student, Teacher, Admin.
You need to think the relevant data attributes for each class.
Define atleast 4 attributes for each class.
• In each class override a method toString() and create a string
which holds all data
• In the method printData in each class print the data using
toString() method.
Design the UML and write a code to solve the above problem.
interface Person{
void printData();
}
class Student implements Person{
String name,course;
int id,grade;
@Override
public void printData() {
System.out.println(toString());
}
@Override
public String toString() {
return "Student{" +
"name='" + name + '\'' +
", course='" + course + '\'' +
", id=" + id +
", grade=" + grade +
'}';
}
}
class Teacher implements Person{
String name,course;
int sal,subjects;
@Override
public void printData() {
System.out.println(toString());
}
@Override
public String toString() {
return "Teacher{" +
"name='" + name + '\'' +
", course='" + course + '\'' +
", sal=" + sal +
", subjects=" + subjects +
'}';
}
}
class Admin implements Person{
String name,department;
int sal,experience;
@Override
public void printData() {
System.out.println(toString());
}
@Override
public String toString() {
return "Admin{" +
"name='" + name + '\'' +
", department='" + department + '\'' +
", sal=" + sal +
", experience=" + experience +
'}';
}
}
OUTPUT :

in java • Create an interface called Person. In this interface create a method called printData()...
Create a Java program for a school. Create a report containing information for a classroom. For each classroom, the report will contain: the room number, the teacher and subject to the class, and a list of students assigned to the class and their grade. Create a directory called “SchoolInfo". Create Displayable interface. The interface should declare one method Create Person (abstract) class String firstName String lastName. (other classes will implement this one) Create the Teacher class, name and subject Create...
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....
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...
a c++ program (The Person, Student, Employee, Faculty, and Staff classes) Design a class named Person and its two subclasses named Student and Employee. Make Faculty and Staff subclasses of 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, and date hired. Use the MyDate classto create an object for date hired. A faculty...
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 Code the following interfaces - An interface called Accountable with void withdraw(double) and double getBalance() methods, and an interface called AccountReceivable with a void deposit(double) method. Save these two interfaces in separate Java files. Then code a class, BusinessAccount, that implements the two interfaces defined above. Define and code the necessary instance variables and constructors. Override toString() so it will return the amount of a business account. Apply the particular operations, such as withdraw and deposit, required in implementing...
In Java
Create an interface called
Amount
that includes a method called
setPrice
().
Create an abstract class named
Book
that inherits from the interface Amount. Include a String field
for
the book’s
title
and a double field for the book’s
Price
. Within the class, include a constructor that
requires the book title and add
two getter methods
— one that returns the title and one that returns the
price. Include an abstract method named
setPrice
().
Create a...
Part I (20%) [File: Student.java] Create a class called Student that has the following stored properties: • StudentID • First Name • Last Name Class Student should have read/write properties, constructor(s) and should implement the Academic interface. For academic methods, return zero for average, zero for credits and false for graduate. Also implement the toString() method that returns the above information as a String. Part II (5%) [File: Academic.java] Create an interface Academic that declares three methods: 1. average -...
Write a Java interface called Salience that includes two methods: setSalience and getSalience. The interface should define a way to establish numeric salience among a set of objects. Design and implement a class called Task that represents a task (such as on a to-do list) that implements the Salience interface. Create a driver class to exercise some Task objects.
Write the following in Java Design an enum called Rating, it has the following names: bad, okay, good, better, best Design a class called Review (reviews might be for a restaurant, movie, etc), it has two attributes: a Rating type called rating, a String type called comment. Design getters and setters for the attributes. Override the toString() method to display both the rating and the comment.