Create a Circle class with the following attribute: double: radius Your class should contain the following methods: A default constructor with one parameter r for radius A copy constructor Accessor and mutator methods / getters & setters Equals0 method to return true if objects have the same radius getArea0 method to calculate and return the area of the circle The toString0 method which return a string with the radius and the area of the object. Static getTotalArea0 method which takes an array of circles as input and calculates the total area of the objects in the array Driver method to demonstrate the correctness of implementation Two arrays filled with circles Display the equivalence of testing every Circle at the same index to the circle in the other array Create an option to have the Circles match at the same index in each array without creating a shallow copy
Q: Please Write a class named Student that has the following variables: name - a string that hold…
A: The program is implemented in C++ with object oriented approach. The question asks me to make 3…
Q: Create a class named Person that holds the following fields: two String objects for the person’s…
A: package Java.C.c; import java.time.LocalDate; class Couple { privatePersonbride;…
Q: 25 dimes is $2.50 4. Create a Student class definition in your Java package. It must have 4 fields:…
A: class Student { private String firstName; private String lastName; private String studentId;…
Q: Create a class named Ship that has two private fields one for the name (string) of the ship, and the…
A: public class Ship { private String name; private String year; public Ship(String name, String year)…
Q: (Geometry: the Circle2D class) Define the Circle2D class that contains: 1 Two double data fields…
A: public class Main { public static void main (String[] args) { Circle2D c1=new…
Q: This is the question - Create a class named Rock that acts as a superclass for rock samples…
A: Rock.java public class Rock { private int sampleNumber; protected String description;…
Q: Define the Circle2DYourLastName class that contains: Two double data fields names x and y that…
A: Actually, array is a collection of elements.
Q: Create a class named FootballTeam. Include two fields that hold data about the teams participating…
A: Note: Three classes has been created for the given criteria. File name: "FootballTeam.java" public…
Q: Design a class named MyPoint to represent a point withx- and y-coordinates. The class contains:■■…
A: UML Diagram:
Q: 1: Create a enum PizzaType, which has the following entries: PIZZA_TYPE_PLAIN,…
A: As per the Bartelby guideline we are suppose to answer only one question at a time.So please repost…
Q: The class will be called "Item" and will represent an item in the game that can be carried and used…
A: #include "Item.h" #include <iostream> #include <string> using namespace std; int main()…
Q: (The MyPoint class) Design a class named MyPoint to represent a point with x- and y-coordinates. The…
A: The no-argument constructor or default constructor takes no arguments as input to the constructor…
Q: A teen ager Sport Club offers many sports to the registered members write a java code to keep…
A: To get the solution of the given problem we create all the classes as follows:
Q: Design a class named Rectangle to represent a rectangle. The class must have the following: •…
A: Program: Filename: “Main.java” class Main { public static void main(String args[]) { Rectangle r1…
Q: Attached you will find a Java class called Employee. This class includes a constructor which sets…
A: The class manager is a Java class which inherits class Employee. Since the data members of class…
Q: RetailItem Class Write a class named RetailItem that holds data about an item in a retail store. The…
A: /*C++ Program to Create a RetailItem class with Constructor, Mutators and Accessors methods*/…
Q: ava. Check ‘n Shop is a grocery supermarket in South Africa that provides a loyalty program to…
A: The given problem is to be solved in Java where 2 classes are needed as below: 1. Shopper.java 2.…
Q: Create a class called Account. Having private fields custname and protected field balance Define a…
A: Step 1: Create class with member variable name and balance Step 2: Accept name and balance Step 3:…
Q: Design a class named Triangle that extends the GeometricObject class. The Triangle class contains:■…
A: SimpleGeometricObject.java public class SimpleGeometricObject { private String color = "white";…
Q: (Geometry: the Circle2D class) Define the Circle2D class that contains: 1 Two double data fields…
A: The question is to write a code for the given problem. As no language has been specified, here C++…
Q: Write Rectangle class to represent a rectangle. The class contains: a. Two double data fields named…
A: public class Rectangle{ //instance variables private double width; private double height;…
Q: Create a class named vehicle. The class has the following members: 1. Private data elements: a.…
A: import java.util.Scanner;//to read input//class vehicleclass vehicle{ //private data elements…
Q: Create a code the follow way: Each student object should also contain the number of earned credits.…
A:
Q: Q1) (The Cylinder class) Design a class named Cylinder The class contains: 1 Two private attributes…
A:
Q: Create a class named Poem that contains the following fields: title - the name of the poem (of type…
A: Approach: Create four classes which are Couplet,Haiku,Limerick which are the derived classes they…
Q: in netbeans Write a complete class named Crab that includes a String property named myColor and an…
A: This is an oops question in which we have to make a class named Crab that includes a String property…
Q: Create an AlienType class. Include at least three protected data members of your choice, such as the…
A: The AlienType class has two sublcasses MartianType and Jupeterian type. The program has been…
Q: 1. Retailltem Class Write a class named Retailltem that hokds data about an item in a retail store.…
A: RetailItem.java public class RetailItem { // variables declaration private String description;…
Q: Create a class named Rock that acts as a superclass for rock samples collected and catalogued by a…
A: In your code you had `1. -------------- these lines which have to be deleted or commented. 2.…
Q: Define the Circle2D class that contains:
A: The UML class diagram for the class Circle2D: The diagram comprises three sections: The first…
Q: (The Triangle class) Design a class named Triangle that extends GeometricObject. The class contains:…
A: UML stands for unified modeling language standard way to visualize the way a system has been…
Q: Design a class named Triangle that extends GeometricObject. The class contains: • Three double data…
A: Steps to be followed: Create a class named GeometricObject Declare two variables: String color and…
Q: Mick’s Wicks makes candles in various sizes. Create a class for the business named Candle that…
A: Purpose of the program: This program would create a class named Candle consisting of the data fields…
Q: The car classwill havethe following attributes: •year: an integer that holds the car's model year…
A: class Car(): def__init__(self,yrModel,make,): self.yearModel=yrModel self.make=make self.speed=0…
Q: Write a class named car that has the following fields: yearModel. The yearModel field is an int that…
A: Note: Since no programming language is mentioned, the program has been written in Java programming…
Q: Create a class named Poem that contains the following fields: title - the name of the poem (of type…
A: Below attached is the complete program of subclasses and super class : import java.util.*;…
Q: Create a TeeShirt class for Toby’s Tee Shirt Company. Fields include: orderNumber - of type int…
A: Program code: filename: TeeShirt.java //define a class TeeShirt public class TeeShirt {…
Q: 02) Design and implement a class named Triangle that extends GeometricObject. Theclass contains: •…
A: Algorithm: Start Create an abstract class named GeometricObject with data members color and filled…
Q: Write a class named Employee that has the following variables : name. The name field references a…
A: A class is a user-defined data type that combines data members and methods for manipulating that…
Q: (The HyPoint class) Design a class named MyPoint to represent a point with x- and y-coordinates. The…
A: Answer
Q: Create a class named Board. The class has the following instance variables, constructors, and…
A: NOTE - I have used the Java programing language. I have created a class named Board. Next, I have…
Q: Create a class called Invoice that a hardware store might use to represent an invoice for an item…
A: Since No Programming Language is specified, we will be answering this question in java.
Q: RetailItem Class Write a class named RetailItem that holds data about an item in a retail store. The…
A: both questions answers are given below:
Q: Car Class Project The car classwill havethe following attributes: •year: an integer that holds the…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: Please enter the description: bananas You entered bananas Please enter the cost: 2.0711 You entered…
A: As per bartleby guideline i have answered only first question( Example 1).
Q: Write a class named Cellphone. The class should contain: Three constants named SHORT, MEDIUM, and…
A: import java.util.*; public class Phone { protected String telecoms_provider; protected…
Q: Create a class named Person that holds the following fields: two String objects for the person’s…
A: Person.java //import packages import java.time.LocalDate; //class Person public class Person {…
Q: Create a class called MarathonRunner that has three private data members: name (String), distance…
A: import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner…
Q: private LocalDate date: private private boolean status; private String appointmentNumber: public…
A: The constructor, getter, setter and toString() method has been added in the class definition.
Q: Write an application that uses an abstract Insurance class and Health and Life subclasses to display…
A: public abstract class Insurance{ protected String type; protected double cost; public…
java language
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 5 images
- a. Write a FractionDemo program that instantiates several Fraction objects and demonstrates that their methods work correctly. Create a Fraction class with fields that hold a whole number, a numerator, and a denominator. In addition: Create properties for each field. The set access or for the denominator should not allow a 0 value; the value defaults to 1. Add three constructors. One takes three parameters for a whole number, numerator, and denominator. Another accepts two parameters for the numerator and denominator; when this constructor is used, the whole number value is 0. The last constructor is parameterless; it sets the whole number and numerator to 0 and the denominator to 1. (After construction, Fractions do not have to be reduced to proper form. For example, even though 3/9 could be reduced to 1/3, your constructors do not have to perform this task.) Add a Reduce() method that reduces a Fraction if it is in improper form. For example, 2/4 should be reduced to 1/2. Add an operator+() method that adds two Fractions. To add two fractions, first eliminate any whole number part of the value. For example, 2 1/4 becomes 9/4 and 1 3/5 becomes 8/5. Find a common denominator and convert the fractions to it. For example, when adding 9/4 and 8/5, you can convert them to 45/20 and 32/20. Then you can add the numerators, giving 77/20. Finally, call the Reduce() method to reduce the result, restoring any whole number value so the fractional part of the number is less than 1. For example, 77/20 becomes 3 17/20. Include a function that returns a string that contains a Fraction in the usual display format—the whole number, a space, the numerator, a slash (D, and a denominator. When the whole number is 0, just the Fraction part of the value should be displayed (for example, 1/2 instead of 0 1/2). If the numerator is 0, just the whole number should be displayed (for example, 2 instead of 2 0/3). b. Add an operator*() method to the Fraction class created in Exercise 11a so that it correctly multiplies two Fractions. The result should be in proper, reduced format. Demonstrate that the method works correctly in a program named FractionDemo2. c. Write a program named FractionDem03 that includes an array of four Fractions. Prompt the user for values for each. Display every possible combination of addition results and every possible combination of multiplication results for each Fraction pair (that is, each type will have 16 results).Create an car class that will be used by a car shop to keep track of inventory. The following attributes should be present in your automobile class: -private string make-private string model-private string color-private int year-private int mileage. The program should have methods such as: -default constructor-parameterized constructor-add a new vehicle method-list vehicle information (return string array)-remove a vehicle method-update vehicle attributes method. All methods should include try..catch constructs. Except as noted all methods should return a success or failure message (failure message defined in "catch"). 1. Create an additional class to call your automobile class (e.g., Main or AutomobileInventory). Include a try..catch construct and print it to the console. 2. Call automobile class with parameterized constructor (e.g., "make, model, color, year, mileage").a) Then call the method to list the values. Loop through the array and print to the screen. 3. Call the remove…Create a class called Invoice in your assignment source package. An Invoice should include four pieces of information as attributes(instance variables) - a part number of type String, a part description of type String, a purchasing quantity of type Int, and a price per item of type double. Your class should have a full constructor that initializes all the four attributes. Provide a set and a get method for each attribute. In addition, provide a method named getInvoiceTotal that calculates the invoice total, purchasing quantity * price per ite, and returns the invoice total. If the quantity is negative, returns 0. Create an test app named InvoiceTest in the same package that demonstrates class Invoice's capabilities.
- 1. Create a class called Student, with the following attributes/variables:a. studentName (String)b. studentNumber (int)sc. regYear(long)d. faculty(String)e. department(String)2. Add the following methods in Student:a. accessors and mutators for all variablesb. toString methodi. Formulate your toString so that it only shows studentName,studentNumber and faculty3. Create a class called MyFriends, with the following attributes variables:a. studentArray(Student[])4. Add the following methods in MyFriends:a. fillArrayi. Using scanner ask how many students does the user want to inputii. Capture user input for all of his friends(Of course we are assuming all your friends would be similarUWC students, go ask around and meet new friends, alsopreferably not in the same Computer Science department … ifpossible … only if possible)b. maini. Call the fillArray methodii. Count how many Computer Science studentsiii. If half or more students are Computer Science students, thendisplay “You … need more…Create a class Car with parameters companyName, color, maxSpeed (Not more than 150) andcategory. Use appropriate data types and access specifiers. Use default constructor to create objectsof cars. Write methods to set and get the values of parameters of car. Write methods to find categoryof car and to display the complete details of car along with category. Create another class TestCarwhich creates array of n number of cars, uses appropriate set methods to set the values of parametersof every car. Display the details of each car. (If max speed is between 120 and 150 then category is“High speed” otherwise “Normal”) (JAVA)Modify the Car class example and add the following: A default constructor that initializes strings to “N/A” and numbers to zero. An overloaded constructor that takes in initial values to set your fields (6 parameters). accel() method: a void method that takes a double variable as a parameter and increases the speed of the car by that amount. brake() method: a void method that sets the speed to zero. To test your class, you will need to instantiate at least two different Car objects in the main method in the CarDemo class. Each of your objects should use a different constructor. For the object that uses the default constructor, you will need to invoke the mutator methods to assign values to your fields. Invoke the displayFeatures() method for both objects and display the variables. Demonstrate the use of the accessor method getColor() by accessing the color of each car and printing it to the console. Use the method accel to increase the speed of the first car by 65 mph. Use…
- Define the Circle2D class that contains: Two double data fields named x and y that specify the center of the circle with get methods. A data field radius with a get method. A no-arg constructor that creates a default circle with (0, 0) for (x, y) and 1 for radius. A constructor that creates a circle with the specified x, y, and radius. A method getArea() that returns the area of the circle. A method getPerimeter() that returns the perimeter of the circle. A method contains(double x, double y) that returns true if the specified point (x, y) is inside this circle. See Figure 10.14(a). A method contains(Circle2D circle) that returns true if the specified circle is inside this circle. See Figure 10.14(b). A method overlaps(Circle2D circle) that returns true if the specified circle overlaps with this circle. See the figure below. Figure (a) A point is inside the circle. (b) A circle is inside another circle. (c) A circle overlaps another circle. Draw the UML diagram for the class.…a) Create an enumeration named Departments that contain four set of values FINANCE, HR, IT, and MARKETING.b) Create a class named PersonDetails that contains fields for a person’s first name (String), last name (String), and address (String). The class have- A constructor that accepts parameters for each field.- Get methods for each field.c) Create a class named Employee that contains fields for an employee ID (int), Social Security number (String), personal information (Person object), department (Departments type), and annual salary (double). The class have- A constructor that requires values for each data field.- Get methods for each of the data fields.- Set methods for each of the data fields.d) Create an application/class named EmployeeSort that allows a user to enter values for an array of 5 Employee objects (create an array of Employee type that will save 5 employee objects). Prompt a user for the data needed to create an employee object. Continue to prompt the user for Social…a) Create an enumeration named Departments that contain four set of values FINANCE, HR, IT, and MARKETING.b) Create a class named PersonDetails that contains fields for a person’s first name (String), last name (String), and address (String). The class have- A constructor that accepts parameters for each field.- Get methods for each field.c) Create a class named Employee that contains fields for an employee ID (int), Social Security number (String), personal information (Person object), department (Departments type), and annual salary (double). The class have- A constructor that requires values for each data field.- Get methods for each of the data fields.- Set methods for each of the data fields.d) Create an application/class named EmployeeSort that allows a user to enter values for an array of 5 Employee objects (create an array of Employee type that will save 5 employee objects). Prompt a user for the data needed to create an employee object. Continue to prompt the user for Social…
- Write Rectangle class to represent a rectangle. The class contains:a. Two double data fields named width and height that specify the width and height ofthe rectangle. The default values are 1 for both width and height.b. A no-arg constructor that creates a default rectangle.c. A constructor that creates a rectangle with the specified width and height.d. A method named getArea() that returns the area of this rectangle.e. A method named getPerimeter() that returns the perimeter.ShoppingCart.java - Class definition ShoppingCartManager.java - Contains main() method Build the ShoppingCart class with the following specifications. Private fields String customerName - Initialized in default constructor to "none" String currentDate - Initialized in default constructor to "January 1, 2016" ArrayList cartItems Default constructor Parameterized constructor which takes the customer name and date as parameters Public member methods getCustomerName() accessor getDate() accessor addItem() Adds an item to cartItems array. Has a parameter of type ItemToPurchase. Does not return anything. removeItem() Removes item from cartItems array. Has a string (an item's name) parameter. Does not return anything. If item name cannot be found, output a message: Item not found in cart. Nothing removed. modifyItem() Modifies an item's description, price, and/or quantity. Has a parameter of type ItemToPurchase. Does not return anything. If item can be found (by name) in cart,…Create a class called Jug that represents a jug of liquid. The UML for this class is shown below: Jug private String liquidType private int gallons public Jug public Jug(String type, int gal) public void setGallons() public void getGallons() public String getLiquidType() public boolean isEmpty() Your class should have the following private state: liquidType (a string) gallons (an integer) Your class should have the following constructors: A default constructor that creates an empty jug of water. A constructor that accepts the type of liquid the jug contains, and the number of gallons the jug contains, in that order. Your class should have the following behaviors: A method called setGallons that allows you to set the number of gallons in the jug. A method called getGallons that allows you to get the number of gallons in the jug. A method called getLiquidType that allows you to get the type of liquid in the jug. A method called isEmpty that returns true if the…