Write the classes as shown in the following class diagram. Add a tester where you make an array of 5 person and ask the user to enter them. Then loop over the array and print them. The user may enter a Student, a Staff or even a Person. The ‘-‘ symbol means private field or method and ‘+’ means public. The classes Student and Staff inherit from Person
Q: public interface Rational { /** * Determines whether this Rational object represents a value less…
A: I give the code in Java along with output and code screenshot
Q: 4. Create an interface Wheel with methods setWheels (int c) and getWheels () and a class Vehicle…
A: Solution: Given,
Q: sign of the Ironman and DoctorStrange class derived from Avengers class so that the following code…
A: We need to define the Ironman and DoctorStrange classes as per the given code and output.
Q: Q2. Write two Java classes: Student and Main as follow: Class Student: A. Create three private…
A: A class is a user-defined data type that combines data members and methods for manipulating that…
Q: Create a Cycle class, with subclasses Unicycle, Bicycle and Tricycle. Demonstrate that an instance…
A: Code : public class Cycle { public static void main(String[] args) { Cycle[] cycles = new…
Q: Implement the constructor and compute method of the Doubler class below. The constructor should set…
A: #include <iostream>using namespace std; class Doubler{ public: Doubler(int start,…
Q: Q#1: Write the class Student having attributes name (String), age (int) and cgpa (double) and…
A: import java.io.*;class Student{ int rollno; String name; int number_of_subjects; int…
Q: Write a RainFall class that stores the total rainfall for each of 12 months into an array of double…
A: import java.text.*; import javax.swing.*; import java.util.Scanner; class RainFall { static…
Q: Question: 2 Implement the design of the Laptop and Store classes so that the following code…
A: Algorithm: Start Create a class Store with laptops a list as static variable and name as instance…
Q: Implement a Shoe class, encapsulating the concept of a shoe A shoe has a color, size, and brand.…
A: public class Shoe { //declaring instance variables private String color; private int size; private…
Q: Write a Clothing class with the following attributes: color (e.g., "blue", "green", "orange")…
A: // Code in java is as follows Clothing{ //clothing class private String color; //color of…
Q: Create a class Student with following data members- name, roll no and marks as private data member.…
A: Operator overloading redefines the meaning of the existing operator. The comparative operators are…
Q: Write the Java code corresponding to the following UML diagram. The class School implements the…
A: Solution: Programming language used: Java Program in Java: (Note: all solution steps are…
Q: 1. Rainfall Class Write a RainFall class that stores the total rainfall for each of 12 months into…
A: The program should have methods that return the following: The total rainfall for the year The…
Q: solve this by arraylist in the last of the question it has been told Create abstract class Pet ,…
A: Program: //Pet.java//Pet abstract classpublic abstract class Pet { private int legs; //Constructor…
Q: elow is the current implementation of TWO classes, Plant (base class) and Flower (derived class).…
A: Here's your code in python:
Q: In Assignment 4, you created a Card class that represents a standard playing card. Use this to…
A: Representing a deck of cards:- To represent a deck of cards, we need 52 Card objects A possible…
Q: name, a student ID, and a GPA. Think carefully about how you shou
A: Step 1: Declare class Student with fields ID, name, GPA. Step 2: Declare getter and setter pairs for…
Q: Write the classes as shown in the following class diagram. Add a tester where you make an array of 5…
A: Java is an object-oriented language, it is used to develop browser applications and mobile…
Q: Write a PaypalAccount class to include both balance and accountID as the instance variables. Make…
A: Java is a programming language was originally developed by James Gosling at Sun Microsystems.
Q: Write Program Java language Create an Animal class and an arraylist from that class you created.…
A: The code for Animal class is written below: class Animal{ // creating Animal class int…
Q: Use java programming language 1.1 Create a Student Object project. Create a Student class and use…
A: Student.java =================== import java.util.Random; public class Student { //declare variables…
Q: Let’s analyze the game Tetris. That game had a lot of different pieces of various shapes and sizes.…
A: If I have to program one game Tetris so there are lots of logical approach to deal with it . In…
Q: Write a class called Rectangle that implements the Comparable The class should contain three fields:…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: Write a program that simulates inventory bins in a warehouse. Each bin holds a number of the same…
A: #include <iostream>#include <iomanip> using namespace std; void DisplayBin (int [],…
Q: In Assignment 4, you created a Card class that represents a standard playing card. Use this to…
A: Actually, Java is a general-purpose also class-based, object-oriented programming language designed…
Q: Using java Hamburger Class Write a Hamburger class with the following six attributes: • bun - the…
A: Actually, in the program given attributes are: Hamburger class with the following six attributes:•…
Q: Suppose that we have the following class: 1 class Book{ 2 private: 3 int id; 4 char name [20]; 5…
A: I have added commands in both codes. I have written a separate code for each question. Also in both…
Q: Q1: Write the Java code corresponding to the following UML diagram. The class School implements the…
A: Solution: Given,
Q: ava Help Please! The Triangle series is a mathematical sequence of integers defined by the formula:…
A: Given: Java Help Please! The Triangle series is a mathematical sequence of integers defined by the…
Q: Write the class Student having attributes name (String), age (int) and cgpa (double) and methods to…
A: The program is made with object oriented approach in C++ programming language. We ha two classes…
Q: Language: Java Write a class encapsulating the concept of daily temperatures for a week with a…
A: Actually, java is a object oriented language. using objects only implement the applications in java.…
Q: Write a program that simulates inventory bins in a warehouse. Each bin holds a number of the same…
A: #include<iostream> using namespace std; class InventoryBin{string desc;int noOfPart;public:…
Q: Class Employee Attributes (all private): id: String lastName: String firstName: String salary: int…
A: Code to Copy: Employee.java: //Import the required packages.import java.text.DecimalFormat;import…
Q: In this java assignment, we will be creating a pay stub for an employee using classes. Each class…
A: The above program makes use of Scanner class defined within java.util package that is used to take…
Q: SOLVE WITH JAVA Q#1: Write the class Student having attributes name (String), age (int) and…
A: Program: import java.io.*;class Student{ int rollno; String name; int number_of_subjects;…
Q: Read the quistion entirely before ansewring the code should compile and run Create a java class…
A: import java.util.Scanner;import java.util.*;import java.lang.*;public class Question2{public void…
Q: Question: 2 Implement the design of the Groceries and Buyer classes so that the following code…
A: I have the same implement program which I done few days and it more useful than this
Q: Write a java code for online food delivery system to manage the data of customers who order the food…
A: Given: Write a java code for online food delivery system to manage the data of customers who order…
Q: Q1: Write the Java code corresponding to the following UML diagram. The class School implements the…
A: Algorithm: Start Implement an interface Building with methods computeArea() and toString() Create a…
Q: art Description Number of Parts in the Bin Valve…
A: #include <iostream>002#include <iomanip> using namespace std; void showBin (int [],…
Q: Use the Lottery class to the left as the superclass. Create the PowerBall class as a subclass of…
A: import java.util.ArrayList;import java.util.Random;class Lottery{public ArrayList<Integer>…
Q: JAVA PROGRAM Create a class EmployeeImp and do the following implement interface EmployeeInterface…
A: An employee is an entity that can have several attributes like id, name, and department, etc. In…
Q: Import Class a) Implement a class Rectangle with two attributes, width and height. b) Implement an…
A: Note: Answering the first three subparts as per the guidelines. Task : Define class name Rectangle…
Q: Implement the above system using inheritance in the best possible way. Keep every object size as…
A: The given system of classes for inheritance are implemented as follows: Class Region acts is…
Q: Write a program that simulates inventory bins in a warehouse. Each bin holds a number of the same…
A: A class is the basic building block of object oriented programming. A class can also contain another…
Q: write the code in java. Write the class Student having attributes name (String), age (int) and cgpa…
A: Given: write the code in java. Write the class Student having attributes name (String), age (int)…
Q: Please help with the following question: In Java without using arrays, Integer.parseInt in the main…
A: import java.util.Scanner; class University{ private String name; private int population;…
Q: erson class. Your class must have the following features: Student - major: String + Student() +…
A: Given : Student inherited from Person class
Q: Please see the below. I have most of it, except for the Inventory class. Would be helpful to see an…
A: import java.util.*; public class Inventory { public static void main(String[] args) {…
JAVA - Person
Write the classes as shown in the following class diagram. Add a tester where you make an array of 5
person and ask the user to enter them. Then loop over the array and print them. The user may enter a
Student, a Staff or even a Person. The ‘-‘ symbol means private field or method and ‘+’ means public. The
classes Student and Staff inherit from Person
Step by step
Solved in 2 steps with 5 images
- Staff # name: String # id: int PartTimer + Staff() + Staff(name: String, id: int) skillLevel: int + getName (): String + getId (): int + calculatePay () : double + toString (): String hoursWorked: int + Part Timer (name: String, id: int, skillLevel: int, hoursWorked: int) + getskillLevel(): int + getHours Worked () : int + tostring () : String java.lang.Comparable compareTo (o: Object): int Figure 1: The relationship between staff, PartTimer and Comparable Skill Level / Tahap Kemahiran Pay Rate Per Hour/ Kadar Bayaran Per Jam 0 ( Basic / Asas) RM50.00 1 (Moderate / Sederhana) RM100.00 RM150.00 2 (Expert / Mahir) Table 1: Skill level and the pay rate per hour Write a complete Java program to create PartTimer class and test class based on the Figure 1, Table 1 and the following requirements: Partimer class is derived from staff and implements Comparable Interface. The calculate Pay()method from the staff class will be implemented in the subclass to calculate the employee's pay. The pay…name: string - ownerName: String Cat numberOfTeeth int lengthofTail : int + Cat (name: String, ownerName: String, numberOfTeeth: int, lengthofTail:int) i. ii. + Pet (name:String, ownerName: String) + getName(): String + getownerName (): String + getNumberOfTeeth (): int + getLengthofTail(): int Pet iii. Budgie colourOfFeathers: String + Budgie (name: String, 1. Convert the UML class diagram above into a java code with the following conditions The methods in the Pet class are abstract. ownerName: String, colourofFeathers:String) + getColourOfFeathers (): String Create a class called test. The main() method in the test class should create three Cat objects and two Budgie objects. The main() method should also create indirectly an object of the Pet class. Demonstrate polymorphism in your test class. 2. Write a Java Code for a simple GUI program that creates a frame and changes the background to green. Examiner's Name: George Kodjo AnniImplement all the classes using Java programming language from the given UML Class diagram. Note: This problem requires you to submit just two classes: Customer.java, Account.java. Do NOT include "public static void main()" method inside all of these classes. Graders will be testing your classes, using the unit-testing framework JUnit 4. Customer - ID:int -name:String -gender:char 'm' or 'f' +Customer(ID:int,name:String, discount:int) +getID():int +getName ():String +getGender ():char +toString():String "name (ID)" The Customer class models, customer design as shown in the class diagram. Write the codes for the Customer class and a test driver to test all the public methods. Account
- function performTask () { var valuel; valuel - document.getElementById ("FirstBox").value; if (valuel == "Yes") { document.getElementById ("paragraphl").innerHTML = "Agreed"; ) else if (valuel =- "No") { document.getElementById ("paragraphl").innerHTML = "Sorry"; ) else ( alert ("Error") Describe the purpose of the following JavaScript statements from the function performTask (). i. alert("Error"), ii. value1 = document.getElementByld("FirstBox").value; iii. document.getElementByld("paragraph1").innerHTML = "Agreed";Static Variable: a variable whose lifetime is the lifetime of the program (static int x;) Dynamic Variable: It is a pointer to a variable (int *x;) Is this comparison true?Trace through the following program and show the output. Show your work for partial credit. public class Employee { private static int empID = 1111l; private String name , position; double salary; public Employee(String name) { empID ++; this.name 3 пате; } public Employee(Employee obj) { empID = obj.empĪD; пате %3D оbj.naте; position = obj.position; %3D public void empPosition(String empPosition) {position = empPosition;} public void empSalary(double empSalary) { salary = empSalary;} public String toString() { return name + " "+empID + " "+ position +" $"+salary; public void setName(String empName){ name = empName;} public static void main(String args[]) { Employee empOne = new Employee("James Smith"), empTwo; %3D empOne.empPosition("Senior Software Engineer"); етрOпе.етpSalary(1000); System.out.println(empOne); еmpTwo empTwo.empPosition("CEO"); System.out.println(empOne); System.out.println(empTwo); %3D етpОпе empOne ;
- Cyclops numbersdef is_cyclops(n):A nonnegative integer is said to be a cyclops number if it consists of an odd number of digits so that the middle (more poetically, the “eye”) digit is a zero, and all other digits of that number are nonzero. This function should determine whether its parameter integer n is a cyclops number, and return either True or False accordingly n Expected result 0 True 101 True 98053 True 777888999 False 1056 False 675409820 False// write a function that takes the input string and reverses it// example// argument: Hello// return: olleHfunction reverseThisString(string){ } // write a function that takes the input string and switches all uppercase characters to lowercase and lowercase charcaters to uppercase// example:// argument: Hello World// return: hELLO wORLDfunction swapCase(string) { } //convert array of numbers from farenheit to celcius// example:// argument: [23, 32, 41, 50, 59]// return: [-5, 0, 5, 10, 15]// hint: use Array.mapfunction toCelcius(array){ } //write a function that takes an input array and returns an array of booleans (>=75) or fail (<75)// example:// argument: [20, 30, 50, 80, 90, 100]// return: [false, false, false, true, true, true]// hint: use Array.mapfunction passOrFail(array){ } //write code that loops through the two variables returns an array ['2 is zwei', '3 is drei', '4 is vier', '5 is fünf', '6 is sechs']// example:// return: ['2 is zwei', '3 is drei', '4 is vier', '5 is…Language : C++ Create a class named myString,which consists of one string data member and three functions. Input the string from the user at run time then call the following functions on it. void CountConsonants( ) //displays the total number of consonants in the string void VowelCount( ) //displays the total vowels in the string void Palindrome( ) //displays if the string is a palindrome or not Use pointer of object to call the member function of the
- class Artist{StringsArtist(const std::string& name="",int age=0):name_(name),age_(age){}std::string name()const {return name_;}void set_name(const std::string& name){name_=name;}int age()const {return age_;}void set_age(int age){age_=age;}virtual std::string perform(){return std::string("");}private:int age_;std::string name_;};class Singer : public Artist{public:Singer():Artist(){};Singer(const std::string& name,int age,int hits);int hits() const{return hits_;}void set_hits(int hit);std::string perform();int operator+(const Singer& rhs);int changeme(std::string name,int age,int hits);Singer combine(const Singer& rhs);private:int hits_=0;};int FindOldestandMostSuccess(std::vector<Singer> list); Task: Implement the function int Singer::changeme(std::string name,int age,int hits) : This function should check if the values passed by name, age and hits are different than those stored. And if this is the case it should change the values. This should be done by…class Artist{StringsArtist(const std::string& name="",int age=0):name_(name),age_(age){}std::string name()const {return name_;}void set_name(const std::string& name){name_=name;}int age()const {return age_;}void set_age(int age){age_=age;}virtual std::string perform(){return std::string("");}private:int age_;std::string name_;};class Singer : public Artist{public:Singer():Artist(){};Singer(const std::string& name,int age,int hits);int hits() const{return hits_;}void set_hits(int hit);std::string perform();int operator+(const Singer& rhs);int changeme(std::string name,int age,int hits);Singer combine(const Singer& rhs);private:int hits_=0;};int FindOldestandMostSuccess(std::vector<Singer> list); Implement the function Singer Singer::combine(const Singer& rhs):It should create a new Singer object, by calling the constructor with the following values: For name it should pass a combination of be the name of the calling object followed by a '+' and then…Implement all the classes using Java programming language from the given UML Class diagram. Note: This problem requires you to submit just two classes: Customer.java, Invoice.java. Do NOT include "public static void main()" method inside all of these classes. Graders will be testing your classes, using the unit-testing framework JUnit 4. Customer - ID:int -name:String -discount:int Discount rate in percent +Customer(ID:int,name:String, discount:int) +getID():int +getName ():String +getDiscount():int +setDiscount(discount:int):void +toString():String "name (ID)" The Customer class models, a customer design as shown in the class diagram. Write the codes for the Customer class and a test driver to test all the public methods. Invoice - ID:int