Create a class called Triangle that has two private instance variables: base and height (double). Additionally, the class should have: (a) A constructor that takes base, and height. The constructor sets the class variables to these values and in case any of these values is negative, set its instance variable to zero. (b) A mutator methods (set) and an accessor methods (get) for the base and height. (c) A method getArea that returns the area of the Triangle. The area is computed by the following formula: base xheight Area= 2 Part (2) Write a Java application that asks the user to enter the base and height. Create an object from Triangle class you did in Part (1) and use it to display the area.
Q: Write a java code , Create a class named Movie that can be used with your video rental business. The…
A: PROGRAMMING APPROACH: Import a package to get the standard input-output. define the class.…
Q: Give a complete definition of a class called TitledPerson, which youderive from the class Person in…
A: Give a complete definition of a class called TitledPerson, which youderive from the class Person in…
Q: Write a class encapsulating the concept of a student, assuming student has the following attributes:…
A: class Student { private String name; private int SSN; private double GPA; //…
Q: Create an HourlyEmployee class that inherits from Employee and has two new instance variables:…
A: public HourlyEmployee() { } public double getWage() { return wage; } public void…
Q: a. create a class called Student that has four instance variables -a (String) name, a (long)…
A: Hi there, Please find your solution below, I hope you would find my solution useful. Thank You!
Q: (Java) Create an HourlyEmployee class that inherits from Employee and has two new instance…
A: Given data, Create an HourlyEmployee class that inherits from Employee and has two new instance…
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: 3) Write a class called Point that represents a point in 2D plane. The constructor accepts the x and…
A: As I have read the guidelines I can provide answers to only 1 part of the questions in case of…
Q: Write a program that accepts two numbers. Use Scanner class to get the user input. Create 4 classes,…
A: Here I have created 3 different classes named Add, Subtract, and Multiply. In all the three classes…
Q: JAVA HELP PLEASE! Write a class Rectangle that has only the following public methods (you can add…
A: java is a programming language originally developed by James Gosling at Sun Microsystems (which is…
Q: Write a Java class called HotelRoom that represents a hotel room. The class will contain the…
A: Java Code for above : class HotelRoom{ int RoomNo; String PhoneNumber; int Capacity;…
Q: For the Circle class, create the following: • A private double instance variable m_radius. • A…
A: i.Class of circle The following class diagram depicts the design of a circle class. It includes the…
Q: Write down a class Time having fields (hrs, mins, secs), containing no argument constructor, three…
A: GIVEN: Write down a class Time having fields (hrs, mins, secs), containing no-argument constructor,…
Q: Consider the following class, write a method that returns the name of the employee object. class…
A: Given :
Q: Create a PhoneListing class that uses the Name class for one of its instance variables. Remember the…
A: The code for the classes Name and PhoneListing is given below: class Name implements…
Q: Create a class called Employee as a a derived class of the class Person. An employee record has an…
A: PROGRAM INTRODUCTION: Define a class named Person. Start definition of another class then extends…
Q: Create a class called RoomCarpet that has three private instance variables – room length and width…
A: The below program is solved using Java Program Below;
Q: WRITE THIS JAVA CODE: A class RentedVehicle that has: - One private instance variable baseFee of…
A: Actually, the code for the above is given below:
Q: consider the following code snippet: class A{ public: A0{ class B: private A{ B); }; main0{ B *b =…
A: Definition: Constructor: It is an object oriented programming language that is based on the…
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: hen: 1) Add a public class constant which set the maximum area to 40.0 2) Add another constructor…
A: Algorithm: Start Create a class Room with attributes WindowNum,length,width Initialize a constant…
Q: (The Rectangle class) Following the example of the Circle class in Section 8.2,design a class named…
A: Note: The given program is compiled and executed in "NetbeansIDE"
Q: Create a class called Employee as a a derived class of the class Person. An employee record has an…
A: Below is the code in java as language is not mentioned and sample output:
Q: can you please answer number 4 for me 1. Create a class called Student, with the following…
A: Class declaration is given below: public class Student{private String studentName;private int…
Q: a class, Team.java, that has the following: * two private instance variables: a String named color…
A: // Java Code: import java.io.*; class Team{ //declaring the private variables private String color;…
Q: Draw the UML diagram for the class and then implement the class. Write a test program that creates…
A:
Q: Create a class, CallClass, with two methods to show call by value and call by reference. One method…
A: C#program to demonstrate Call by Value and Call by Reference methods.using System;namespace…
Q: Create a class called Employee as a a derived class of the class Person. An employee record has an…
A: Create a class called Employee as a a derived class of the class Person. An employee record has an…
Q: In this lab you will write three classes: Die, PairOfDice, and Player. The Die class mimics the…
A: import java.util.Random;public class Die { private int sides; private int face; public…
Q: Write a class named IceCreamcup that implements the Customizable interface. The class should have…
A: Write class named IceCreamCup that implements Customizable interface having the following private…
Q: Create a class called RoomCarpet that has three private instance variables – room length and width…
A: Create a Java class that has the private double data of length, width, and price. Create the gets…
Q: Create an HourlyEmployee class that inherits from Employee and has two new instance variables:…
A: Employee.java ------------------------------------------- public class Employee { //creating…
Q: Write a class encapsulating the concept of the weather forecast, assuming that it has the following…
A: Since programming language is not mentioned in the question, we will answer this question in the…
Q: Design a class called circle which contains: -Two instance variables: radius (type double) and color…
A: As per our company guidelines, we are supposed to answer only one question per post and kindly…
Q: Given this class, please add the requested methods in the designated spaces provided. Instance…
A: public class Student { // declare instance variables here private int ID; private String…
Q: Create a class, OverloadingClass, with four overloading methods, each of which has parameters,…
A: If more than one method shares the same method name with different parameter(parameter…
Q: Create a class “Pizza”, and three sub-classes “Cheese Pizza”, “Pepperoni Pizza” and “VeggiePizza”.…
A: Code: // Pizza.javapublic class Pizza{ private String pizzaSize; private int cheeseCount; private…
Q: In this lab you will write three classes: Die, PairOfDice, and Player. The Die dass mimics the…
A: Q: Code the given problem in java
Q: Build a class called BankAccount that manages checking and savings accounts. The class has three…
A: we need to provide python code for given Bank Account class
Q: 1) Write a class called Room, which has three private instance variables: a) a double width,…
A: Explanation : The code is self explanatory. Here are some key points: Instance variables are…
Q: Your task is to implement the following DigitalWallet class. The description of the class is as…
A: In this question we have to write a JAVA program, Where DigitalWallet class has to be executed with…
Q: Write a class called Pants that contains the following information: 1. Private instance variables…
A: use throw new IllegalArgumentException() to throw this kind of exception when input is beyond range.…
Q: Write a class that represents a digital snowman. Your class should follow these guidelines: 1. Store…
A: A program that satisfies the given criteria is as follows, File name: “DigitalSnowMan” import…
Q: Write a class called person, which contains: A private class variable, Counter, initialized with…
A: //C++ program#include <iostream> using namespace std; class person{ //class variable…
Q: Assume there is a class Phone with a private attribute named model. Write a method named someMethod…
A: Given:
Q: Build a class called BankAccount that manages checking and savings accounts. The class has three…
A: import pickle import os import pathlib class Account : accNo = 0 name = “ deposit=0 type…
Q: Write a class 'Cylinder' that has two fields: height and radius. The class should have only one…
A: Since no programming language is mentioned, I am using python. Algorithm: Start Create a class…
Q: Block class The Block class inherits from Drawable and it will draw a square with a black outline at…
A: The Drawable class is implemented as shown. Class Block inherits class Drawable and implements the…
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
- Hi can you assist me on the problem below for a class and a test class that conforms to the following specifications: 1. The name of the class is RightTriangle 2. The class has member variables base and height 3. The class has a constructor that initializes base and height 4. The class has accessors and mutators for base and height 5. The class has a toString method that produces String representation of a RightTriangle like the following example for a triangle with base 12 and height 10. Base : 12 Height 10 6. The class has a method called findArea to compute the area of the right triangle. Here is a suggested implementation. public double findArea() { return 0.5* this.base*this.height; } 7. The class using proper naming conventions Write a test class called RightTriangleTest that conforms to the following: 1. Create an object with base = 10 and height = 20, for example myTriangle. 2. To print the toString for myTriangle. 3. To print the area of myTriangle. System.out.println(“The…1) Change the visibility of the variables and constructor in the Employee class to be more secure 2) Add an Admin class with the following features: a) The Admin class is a child of the Employee class b) Admin objects have an instance string password variable c) The Admin class has a 4 parameter constructor. One parameter sets the string, the other three parameters are used as arguments for a parent constructor call. d) Admin objects have an instance getInformation() method with a void return and an Employee object parameter. The method will request the calling Admin’s password and check user input. If input matches the password, the method will display the information of the Employee parameter Please use ***C Sharp** Language to answer the codeCan you help me with this please: Write the definition of a class swimmingPool, to implement the properties of a swimming pool. Your class should have the instance variables to store the length (in feet), width (in feet), depth (in feet), the rate (in gallons per minute) at which the water is filling the pool, and the rate (in gallons per minute) at which the water is draining from the pool. Add appropriate constructors to initialize the instance variables. Also, add member functions to do the following: determine the amount of water needed to fill an empty or partially filled pool, determine the time needed to completely or partially fill or empty the pool, and add or drain water for a specific amount of time, if the water in the pool exceeds the total capacity of the pool, output "Pool overflow" to indicate that the water has breached capacity. The header file for the swimmingPool class has been provided for reference. Write a program to test your swimmingPool class. An example of…
- a.) Write the definition of the default constructor of YClass so that the instance variables of YClasa are initialized to 0. b.) Write the definition of the default constructor of XClass so that the instance variable of XClass are initialized to 0. c.) Write the definition of the method two of YClass so that rhe instance variable a is initialized to the value of the first parameter of two, and the instance variable b is initialized to the value of the second parameter of two.What does the super keyword represents and where can it be used? Give an example of a superclass and subclass. Be sure to make all the instances variables of the super class private. Include at least one constructor in each class and ensure that the constructor of the subclass calls the constructor of the superclass. Also include a toString method in both classes that returns the values of the instance variables with appropriate labels. Ensure that the toString method of subclass calls the toString method of the superclass so that the string returned contains the values of all the inherited instance variables.Given this class, please add the requested methods in the designated spaces provided. Instance methods: a) Write two constructors that will initialize the instance variables for a Student instance as follows: 1) Write a constructor that takes in three parameters – an int, a String, and a double. The constructor will assign them to the ID, name, and GPA instance variables respectively. 2) Write a no-argument (zero-parameter) constructor that will set the ID to - 1, the name to “No name assigned”, and the GPA to –1.0. b) Write an accessor method for the name variable. c) Write a mutator method for the GPA variable. d) Write a toString() method that will display all three instance variables on a single line, with a | (vertical bar) character between each one. e) Write an equals() method that returns true only if all three instance variables are equal. public class Student { // declare instance variables here private int ID; private String name; private double GPA;
- Complete the FoodItem class by adding a constructor to initialize a food item. The constructor should initialize the name (a string) to "None" and all other instance attributes to 0.0 by default. If the constructor is called with a food name, grams of fat, grams of carbohydrates, and grams of protein, the constructor should assign each instance attribute with the appropriate parameter value. The given program accepts as input a food item name, fat, carbs, and protein and the number of servings. The program creates a food item using the constructor parameters' default values and a food item using the input values. The program outputs the nutritional information and calories per serving for both food items. Ex: If the input is: M&M's 10.0 34.0 2.0 1.0 where M&M's is the food name, 10.0 is the grams of fat, 34.0 is the grams of carbohydrates, 2.0 is the grams of protein, and 1.0 is the number of servings, the output is: Nutritional information per serving of None: Fat: 0.00 g…Write a class named Employee which implements Comparable Interface with name and salary as data fields Add a constructor with argument name and salary. Add getter and Setter for name and salary. Add CompareTo() method for the data Salary. Write a class named Manager which inherits the Employee class. Add an instance variable, named department, of type String. Add a constructor in the subclass class with arguments name, salary, department and a toString() method that prints the manager’s name, department, and salary [Hint: Add a toString( ) method in the super class as well] Create 3 objects of Manager with following arguments 1. (Zayed, 500), 2. ( Ahmed, 700) 3. ( Faisal, 600) Add the above 3 objects into an ArrayLIst object and Sort by Salary and Display. Create an object Employee class with (Zayed, 500,IT) and display the 1. Name 2. Salary 3. Department by using tostring() method.This question involves the design of a class that will be used to produce practice problems. The following StudyPracticeinterface represents practice problems that can be used to study some subject. public interface StudyPractice. { /**Returns the current practive problem */ String getProblem(); /** Changes to the next practice problem */ void nextProblem(); } The MultPractice class is a StudyPracticethat produces multiplication practice problems. A MultPractice object is constructed with two integer values: first integer and initial second integer. The first integer is a value that remains constant and is used as the first integer in every practice problem. The initial second integer is used as the starting value for the second integer in the practice problems. This second value is incremented for each additional practice problem that is produced by the class. For example, a MultPractice object created with the call new MultPractice (7, 3)would be used to create the practice…
- Write a class named Employee which implements Comparable Interface with name and salary as data field. Add a constructor with argument name and salary. Add getter and Setter for name and salary. Add CompareTo() method for the data Name. Write a class named Manager which inherits the Employee class. Add an instance variable, named department, of type String. Add a constructor in the subclass class with arguments name, salary, department and a toString() method that prints the manager’s name, department, and salary [Hint: Add a toString( ) method in the super class as well] Create 3 objects of Manager with following arguments 1. (Zayed, 500), 2. ( Ahmed, 700) 3. ( Faisal, 600) Create an Array object Add the above 3 objects into an Array object and Sort by Name and Display Create an object Employee class with argument (Zayed, 500, IT) Display the 1. Name 2. Salary 3. Department by using tostring() method.Write a class encapsulating the concept of the weather forecast, assuming that it has the following attributes: the temperature and the sky conditions (e.g. sunny, snowy, cloudy, rainy, etc.). Include a default constructor, an overloaded constructor, accessors and mutators, and the methods, toString() and equals(). Temperature, in Fahrenheit, should be between -50 and +150; the default value is 70, if needed. The default sky condition is sunny. In Addition, include a method that converts Fahrenheit to Celsius. Celsius temperature = (Fahrenheit temperature – 32) * 5/9. Also include a boolean method that checks whether the weather attributes are consistent (there are two cases where they are not consistent: when the temperature is below 32 and it is not snowy, and when the temperature is above 100 and it is not sunny). Write a client class to test all the methods in your class.Problem B Now we are going to use the design pattern for collecting objects. We are going to create two classes, a class AmazonOrder that models Amazon orders and a class Item that models items in Amazon orders. An item has a name and a price, and the name is unique. The Item class has a constructor that takes name and price, in that order. The class also has getters and setters for the instance variables. This is the design pattern for managing properties of objects. The setName() method should do nothing if the parameter is the empty string, and the setPrice() method should do nothing if the parameter is not positive. The class also has a toString() method that returns a string representation for the item in the format “Item[Name:iPad,Price:399.99]”. For simplicity, we assume an Amazon order can have at most 5 items, and class AmazonOrder has two instance variables, an array of Item with a length of 5 and an integer numOfItems to keep track of the number of items in the…