3. Suppose class called Student that defines four instance variables: name (string), age (integer), marks (2D for store marks (double)for 6 lesson in 4 years ), averages(1D for store averages(double) of 4 years) And three method: • readinfo for read data for student. printinfo for print student name and average for student. Average for calculate averages of 4 years. Write a program that test methods in the class.
Q: Set the last name only. Set the first name only. Set the middle name. Check whether a given last…
A: Note: Since you have not provided the language to write the code so I am using java language to…
Q: use Java. Given the following class. public class FamilyMember { public String drink( )…
A: logic:- define a parameterized constructor in Baby class. Baby(int age) {…
Q: Write a java program that defines an enumerated type named Rank with values: ace, two, three, four,…
A: The program is written in Java. Please check the source code and comments in step 2.
Q: The weight of an object can be described by two integers: pounds and ounces (where 16 ounces equals…
A: Program Plan: Implement a compareTo method as follows: Call and return the compare function with…
Q: 3. Consider the scenario of a "BookStore" which is descnibed by its bookld, author, title, price,…
A: #include<iostream>#include<string.h>#include<stdlib.h> using namespace std; class…
Q: Define a new "Degree" class that contains a year (integer), a subject (string) and a person's name…
A: Hey there, I am writing the required solution based on the above stated question. First, I will…
Q: write easy java program. Make a class Employee with a name and salary. Make a class Manager…
A: Code is in step 2 and output in step 3 Programming instructions: Create a class Employee. In the…
Q: Question: 2 Implement the design of the Chillox and Customer classes so that the following code…
A: Algorithm: Start Create Chillox class with menu and order_id as its static varibales Implement…
Q: I just want you to do the second part only using java class, but i have attached the answer for…
A: Solution:: Assignment 1: public class LoanAccount { // properties…
Q: Consider a class Time that represents a time of day. It has attributes for the hour and minute. The…
A: Consider a class Time that represents a time of day. It has attributes for thehour and minute. The…
Q: Exercise 2: A. Write static methods: public static double cubeVolume(double h) : h3 public static…
A: The Java OOPS code to do the job described in problem statement is: Part A) Keeping cube, Cylinder…
Q: In a package named "lecture10", implement the following. Lecture Question • class Battery with • A…
A: Given:
Q: In a package named "lecture10“, implement the following. Lecture Question • class Battery with • A…
A:
Q: Exercise 3: Create class Date with following instance variable and methods. Instance variables:…
A: Create class Date with following instance variable and methods. Instance variables: private int day,…
Q: Now write a Demo class which contains main method in order to demonstrate the behavior of all…
A: public class Main{ public static void main(String[] args) { //create Circle instace and…
Q: IN C++ Implement a class Car with the following properties. A car has a certain fuel efficiency…
A:
Q: in JAVA Assume that a receipt id contains characters that represent information or that can be used…
A: Below I have provided a java program for the given question. Also, I have attached a screenshot of…
Q: In this exercise, you are going to create the Problem class. The Problem class is used to help…
A: Given code:- import java.util.*;class ProblemTester{String x;ProblemTester(String op,int min,int…
Q: 2. Consider a class Time that represents a time of day. It has attributes for the hour and minute.…
A: Note: I am using python as the programming language is not mentioned. The program given below is…
Q: Given a class Student that represents names and grades of a class: 1. How would we implement the…
A: The given problem is related to Java programming where the class Student needs to implement the…
Q: Write the source code of the class Passenger. A passenger can travel with an infant (i.e. his/her…
A: Programming instructions: Include necessary header files. Create a class Passenger. In the…
Q: 1/ Implement a class Employee. An employee has a name (a string) and a salary (a double). Provide a…
A: Note: This is a multiple-question-based problem. The only first question is solved. Kindly send the…
Q: 4. Complete the following class to implement all the methods in the class: public class Person {…
A: public class Person { String name; int birthYear; public Person() { name="unknown";…
Q: Consider the following classes: public class Topl int x; public Top (int x) { this.x = x + 1; }…
A: What will be displayed on screen from the Java code?
Q: and assign to it the average number of yards Barkley has gained per carry. This line of code (3) On…
A: Below is the required code and sample output:
Q: Consider the following classes: public class Top{ int x; public Top (int x){ this.x = x + 1; } }…
A: The solution to the give java program is given below.
Q: Consider the following program which contains a class definition currently missing one line of code:…
A: Given:
Q: 2. Suppose class called Student that defines three instance variables: name (string), age (integer),…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: ) Implement a class Point with three attributes, x, y, and z. b) Implement an init method with an…
A: GIVEN: Create a program for the above question. NOTE: As programming language is not mentioned, we…
Q: write the definition of a class Player containing: an instance variable name of type string,…
A: According to the Question below the Solution:
Q: Consider the following class Date, which represents a date using three ints for month, day and year:…
A: The program is written in C++ The code for bool operator==(Date) is: bool operator ==(const…
Q: 13. Consider the following code, just write one line of code in method10 to print the sum of two…
A: int z; z= o.x+o.y
Q: Write a java class called House with the following two private attributes, and three methods:…
A: The classes House and HouseMap are given below and their formatted image version: public class…
Q: Exercise 3: A. Write static methods: public static double sphereVolume(double r) :ar public static…
A: Geometry.java public class Geometry{ public static double sphereVolume(double r) { return…
Q: ng method must return all the degree information: year, subject and person’s name in the following…
A: Here is C++ program:
Q: in JAVA Assume that a receipt id contains characters that represent information or that can be used…
A: Below I have provided a java program for the given question. Also, I have attached a screenshot of…
Q: 4. Complete the following class to implement all the methods in the class: public class Person {…
A: JAVA CODE- public class Person { String name; int birthYear; //constructor public…
Q: Task: Implement the following class and test its methods Account -accountNumber:int -balance:double…
A: Given:
Q: Exercise 2: Create class Account with following instance variable and methods. Instance variables:…
A: The above question is asking to create a class named Account for managing the balances and accounts.…
Q: Consider the following program which contains a class definition currently missing one line of code:…
A: In python , The parameterized constructor takes its first argument as a reference to the instance…
Q: Lab 6 - Exercise 2. Write a test driver that reads data about two surgeons and print the A Doctor…
A: public class Doctor { //declaring data memebers private String name; private int salary;…
Q: In a package named "lecture10", implement the following. Lecture Question class Battery with A…
A: Given
Q: Using JAVA Language Consider a Billing class that implements an interface Payable having a method…
A: Solution: //java Program: //Doctor.java //class Doctorpublic class Doctor { // Declaring Instance…
Q: Consider the following Student Class An. EngineeringStudent "is-a" Student whose major is…
A: EngineeringStudent is a student whose major is Engineering. Therefore this class needs to extend the…
Q: a) Design the child class ExtClock from the class Clock by adding a data member to store the time…
A: Objective: This program implements a time zone using the parent class Clock. Here, we need to…
Q: Consider the following design for a Product class that keep track of product inventory:
A: 1. Create two product soft roll with name soft roll and quantity 25 and Hard rolls with name Hard…
Q: Write a java class called House with the following two private attributes, and three methods:…
A: Class is a user-defined custom data type that encapsulates the data members and member…
Q: Write a Java class called HotelRoom that represents a hotel room. The class will contain the…
A: Given: Write a Java class called HotelRoom that represents a hotel room. The class will contain the…
Step by step
Solved in 4 steps with 3 images
- Write a complete program for the description given below. Consider a Billing class that implements an interface Payable having a method getTotalPayment Amount(). Besides this, you have a Doctor class with private instance variables (docID, docName, and docFee) and a public getDoc() method, Patient class with private instance variables (pName, pID. pDisease), Medicine class with private instance variables (medID, medName, medQty, medPrice), and Medical Test class with private instance variables (testID, testName, testPrice). Each of these classes has the toString() method to display the information of its object. The Billing class is having "Has A" relationship with the other four classes (Doctor, Patient, Medicine, and MedicalTest) mentioned above. The getPayment Amount() method of Billing class returns the total billing amount that includes doc fee, medicine cost, and medical test fee that a patient has to pay. After implementing these classes, you are required to do the following in…box1 and box2 are instances of the Box class. Attributes length, width, and height of both box1 and box2 are read from input. Then, two strings are read from input. In the Box class, define instance method print_measurements() with self and one string as parameters to output the string parameter in one line, and the following in the next line: The value of attribute length ' by ' The value of attribute width ' by ' The value of attribute heightwrite the following 3 classes for the Java program so that this program produces the sample output shown at the end of Main. ElectricCar: a vehicle with a limited range. So it must be a subclass of Vehicle, and it must implement LimitedRange. Thus it needs an instance variable for its range, and a travel method (required by Vehicle. Please use @Override) that outputs "Zoom!" if it has enough range to go the distance specified (and update its range). It must have a constructor with 3 arguments as called by main. It also needs a getCurrentRange method as required by LimitedRange (use @Override for this too). Motorboat: a vehicle with a limited range. So it is similar to ElectricCar, but it outputs "Wisshhh!" when it goes. Sailboat: a vehicle that doesn't have a limited range. So it is a subclass of Vehicle, but doesn't implement LimitedRange. It can go any distance, and outputs "Weee!" when it travels. Code: class Main { publicstaticvoid main(String[] args) { Vehicle[]…
- Write a class Point with instance variables as: xCoordinate(int) and yCoordinate(int). Write public instance methods (getters & setters) for each instance variable. Now, write a class Circle with private instance variables as radius and Pi (value is 3.14). Write public setter, getter for radius, Area method for calculating Area, Draw method for radius. Formula for calculating area=pi*r^2 Formula for calculating radius= sqrt (xCordinate^2+yCordinate^2) Extend a Circle class from Point class such as Class Circle extends Point Write a Default constructor in Circle class that sets radius, xCoordinate & yCoordinate to some default value e.g. -1; Write a Parameterized constructor in Circle class which takes xCoordinate, yCoordinate and radius as a parameter. E.g. Circle (int xCoordinate, int yCoordinate, double radius) { this.xCoordinate= xCoordinate; this.yCoordinate= yCoordinate;…Write a Java program for a class named Baby. A Baby has a name of type String and an ageof type integer.Supply two constructors: one will be the default constructor, that just setsdefault values for the name and age; the second constructor will take twoparameters, a string to set the name and an integer to set the age. Also, supplymethods for setting the name, setting the age, getting the name and getting theage.The class should not contain I/O methods; input of values to the instancevariables must be done with a set method or constructor, output of values fromthe instance variables must be done with get methods. The set method for thename instance variable should ensure that the input is not empty or containwhitespaces (otherwise set a default value). The set method for the ageinstance variable should validate the input to be between 1 and 4 inclusive(otherwise set a default value).Give Java code for an equals method for the Baby class. Babies count asbeing the same (i.e. equal) if…IN C++ Implement a class Car with the following properties. A car has a certain fuel efficiency (measured in miles/gallon or liters/km—pick one) and a certain amount of fuel in the gas tank. The efficiency is specified in the constructor, and the initial fuel level is 0. Provide another parameterized constructor which takes both efficiency and fuel as parameters. Also supply methods getGasInTank, returning the current amount of gasoline in the fuel tank. getEfficiency() return the efficiency of car. setGasInTank(double fuel), to add gasoline to the fuel tank. setEfficiency(double efficiency) Supply a method Drive () that simulates driving the car for a certain distance, reducing the amount of gasoline in the fuel tank according to its efficiency. Sample usage: Car myHybrid (50); // 50 miles per gallon myHybrid.addGas(20); // Tank 20 gallons myHybrid.Drive(100); // Drive 100 miles double gasLeft = myHybrid.getGasInTank(); // Get gas remaining in tank Supply a main method that tests…
- In Java Programming: Example, 8-8, defined the class Person to store the name of a person. The methods that we included merely set the name and print the name of a person. Redefine the class Person so that, in addition to what the existing class does, ypu can: 1. Set the last name only. 2. Set the first name only. 3 Set the middle name. 4. Check whether a given last name is the same as the last name of this person. 5. Check wether a given first name is the same as the first name of this person. 6. Check whether a given middle name is the same as the middle name of thi person. 7. Add the method equals that returns true if two objects contain the same first, middle, and last name. 8. Add the method makeCopy that copies the instance variables of a Person object into another Person object. 9. Add the method getCopy that creates and returns the address of the object, which is a copy of another Person object. 10. Add a copy constructor. 11. Write the definitions of the methods of the class…Write the classes for the Java program to run as the sample below Data: Occupation,Number of workers,Location quotient,Mean Hourly Wage,Mean Annual WageComputer systems analysts,15450,1.6,60.27,125350Information security analysts,2590,1.1,65.82,136910Computer and information research scientists,2330,4.6,78.53,163330Computer network support specialists,2840,0.9,42.8,89020Computer user support specialists,15640,1.5,37.82,78670Computer network architects,4550,1.7,71.27,148250Network and computer systems administrators,6700,1.2,51.3,106700Database administrators and architects,3830,1.7,55.16,114730Computer programmers,5690,1.9,60.3,125420Software developers and software quality assurance analysts and testers,64310,2.6,69.59,144740Web developers and digital interface designers,5990,2.3,54.76,113910Computer occupations (all other),21270,3.5,60.33,125480Actuaries,380,1,53.12,110500Mathematicians,50,1.1,65.38,135980Operations research…Write a class Point with instance variables as: xCoordinate(int) and yCoordinate(int). Write public instance methods (getters & setters) for each instance variable. Now, write a class Circle with private instance variables as radius and Pi (value is 3.14). Write public setter, getter for radius, Area method for calculating Area, Draw method for radius. Formula for calculating area=pi*r^2 Formula for calculating radius= Math.sqrt (xCordinate^2+yCordinate^2) a. Extend a Circle class from Point class such as Class Circle extends Pointb. Write a Default constructor in Circle class that sets radius, xCoordinate & yCoordinate to some default value e.g. -1;c. Write a Parameterized constructor in Circle class which takes xCoordinate, yCoordinate and radius as a parameter.Now write a ColoredCirlce class with private instance variable as color (String) and public setter & getters. Extend the ColoredCircle from Circle and do the following operations.d. Write a default constructor…
- (Java) Question 6 Explain the answer step-by-step and include verbal explanation. Thank you! Given the below Tesla class, update the class to inherit from the Comparable interface and also write a compareTo method that orders two Tesla objects according to 1. model, 2. range, and 3. color: public class Tesla { private String model; private int range; private String color; public Tesla(String model, int range, String color) { this.model = model; this.range = range; this.color = color; } @Override public boolean equals(Object o) { if (this == o) return true; } else if (!(o instanceof Tesla)) { return false; } else { Tesla t = (Tesla) o; return model.equals(t.model) && range == t.range && color.equals(t.color); } }}Write a Java Program, Create a class with a method that prints "This is parent class" and its subclass with another method that prints "This is child class". Now, create an object for each of the class and call 1 - method of parent class by object of parent class 2 - method of child class by object of child class 3 - method of parent class by object of child class In the above example, declare the method of the parent class as private and then repeat the first two operations (You will get error in the third).Consider a class that could be used to play a game of hangman. The classhas the following attributes:- the secret word- the disguised word, in which each unknown letter is replaced with a question mark (?). For example, if the secret word isabracadabra and the letters a, b, and e have been guessed, the disguisedword would be ab?a?a?ab?a.- the number of guesses made- the number of incorrect guessesIt will have the following methods:- makeGuess(c) guesses that character c is in the word.- getDisguisedWord returns a string containing correctly guessed letters in their correct positions and unknown letters replaced with ?.- getSecretWord returns the secret word.- getGuessCount returns the number of guesses made.- isFound returns true if the hidden word has been discovered.a. write method heading for eeach methodb. write preconditions and postconditions for each methodc. write some java statements that test the classd. Implement the class.2. Write an application that plays the game of…