Suppose there is a class named Book having an attribute named price , a default constructor and setPrice method. Fill in the missing code for the following code snippet to set the price of all the books to 30. 1. Book[] books = new _[10]; 2. 3. //Loop to set the price for each Book 4. 5. for (int i = 0; i< _ ; it) 6. { 7. = new Book(); 8. 9. books[i].setPrice(30); 10. }
Q: Please do P1 by redefining and using the student.py code. Strictly use the student.py code, you can…
A: Here is the approach :- To compare two students is to comapre their marks or scores . But to…
Q: Exercise: I A company pays its employees on a weekly basis. The employees are of four types:…
A: Please refer to the screenshot of the code to understand the indentation of the code. package :…
Q: In this question, we will bake a class. Create a class Cake, with the following instance attributes:…
A: Answer:
Q: Create class for Electricity for N flats of an apartment. The required details are Flat number, EB…
A: /******************************************************************************…
Q: Create an car class that will be used by a car shop to keep track of inventory. The following…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: in python how do you (1) Build the ItemToPurchase class with the following specifications:…
A: class ItemToPurchase: def __init__(self, item_name = "none", item_price = 0, item_quantity = 0):…
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: Lecture Question In a package named "lecture11“, implement the following to expand the Flashlight/…
A: BoomBox.scala class BoomBox(override var battery: Battery) extends Electronic(){ this.accum =…
Q: Preliminaries • Write a Point class with two properties: r, y. Write required constructor, get &…
A: NOTE: As per the policy we can answer only one question at a time, kindly repost the other part to…
Q: Java Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A, B, C, D, E"…
A: The correct answer is (E) Seed Explanation: The composite class known as a concrete component class…
Q: Task: 1. Park class with the following class variables: 1) String ParkName; 2) int ParkID; 3)…
A: Actually, given information: Park class with the following class variables: 1) String ParkName; 2)…
Q: lass contains three independent static methods and contains no fields (none should be added). The…
A: It is defined as a user defined blueprint or prototype from which objects are created. It…
Q: Please do it as as possible Question: 2 Implement the design of the BFC and Customer classes so…
A: Algorithm: Start Create BFC class with menu and order_id as its static varibales Implement…
Q: Modify the Date class below by adding a new method called nextDay() that increments the Date by 1…
A: Explanation: Your program logic is correct. But the issue is based on syntax error(open and close…
Q: Implement the following class and invoke discountedPrice(): > Discountable discountedPrice (price:…
A: Objective: This program includes an interface and a class implementing the interface. The interface…
Q: This program should be written in Java: Hamburger Joint: Hamburger Class Write a Hamburger class…
A: import java.util.*;public class Hamburger { String type; int patties; int cheese; double price;…
Q: wing code provides the expected output. [addGrandSlams() method should work any number of parameters…
A: Q. Design TennisPlayer class which inherit from Player class so that the following code provides the…
Q: Complete the following code for a method that returns the number of elements in an array of objects…
A: PROGRAM CODE: Following is the complete program code that represents the demonstration of the given…
Q: Create a class namely Circle and do the following: (i) Circle will have the following member…
A: The program is written in java
Q: ate a class Rectangle with parameters length, breadth, and color. Use appropriate data types and…
A: public class TestRectangle { public static void main(String[] args) { Rectangle r1=new…
Q: Write the CheckingAccount class so that the following code generates the output below: class…
A: numberOfAccount is a class level variable which can be accessed by using class name and this gets…
Q: Modify the Date class below by adding a new method called nextDay() that increments the Date by 1…
A: import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.Calendar; //Date…
Q: Create a class Employee with parameters name, id, designation, and basicSalary. Use appropriate data…
A: Since programming language is not mentioned to programming language used is Java. Create Employee…
Q: Suppose we have a Farmer class defined as follows: public class Farmer{ String name; double weight;…
A: The solution to the given problem is below.
Q: Create a calculator using a class, the class must accept two values as parameters/arguments, then…
A: A class is a basically an blueprint of an object, and an object is an instance of class.
Q: Implement the design of the Pizza class so that the following output is produced: # Write your…
A: The Pizza class has four variables to store the data values for the object of the pizza. The three…
Q: This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier…
A: the answer is given below:-
Q: 1) Implement the class Doctor: a) The name could be composed from more than one word. b) The…
A: Given, One class doctor. There all are private variables. create some getter and setter method and…
Q: Create a MyTime class which is designed to contain objects representing times in 12-hour clock…
A: The classes are designed as per the requirement in the next step:
Q: in java You are required to design an item class which has following attributes String…
A: class Item{ //data members private String name; private int stock; private int price; private String…
Q: public class BackAccount { public double Balance { set; get; } public void Deposit(double amount) {…
A: Using code snippet above complete the bank account functionality..
Q: Write a class called Hamburger. The Hamburger class should have the following fields: weight – an…
A: The Hamburger class should have the following fields: weight – an int storing the weight of the…
Q: Write a public int method named initialNumberOfSticks which takes two int parameters named…
A: public int initialNumberOfSticks(int max_sticks, int min_sticks ) { Random r = new…
Q: In many card games, cards are either face up or face down. Add a new instance variable named faceup…
A: Programming is a way to instruct the computer devices to operate. Every computer needs a set of…
Q: n many card games, cards are either face up or face down. Add a new instance variable named faceup…
A: According to the information given:- We have playing cards in that they are either face up or face…
Q: Build the ItemToPurchase class with the following specifications: Attributes item_name (string)…
A: Coded using Python 3.
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: In main.py define the Product class that will manage product inventory. Product class has three…
A: Introduction In main.py define the Product class that will manage product inventory. Product class…
Q: The weight of an object can be described by two integers: pounds and ounces (where 16 ounces equals…
A: Source Code Weight.java public class Weight{ private int pounds; private int ounces;…
Q: Given the following class: public class Student { private long ID; private String name;…
A: Programming instructions: Create a Student class. Create variables. Create constructor without…
Q: In this question, we will bake a class. Create a class Cake , with the following instance…
A: import random class Cake: name = "" ingreds = [] price = 0 #Constructor def…
Q: You are required to build a class to represent the a cup of coffee. Call your class CoffeeCup. A…
A: Algorithm: Start Create a class CoffeeCup with type,temp,volume and sugar as its attributes…
Q: Create another class TestCar which creates array of n number of cars, uses appropriate set methods…
A: As you have not mentioned any structure for class Car I am considering following structure. Car…
Q: Complete the following code for a method that returns true if there is at least one element with a…
A: public boolean practice(student[] aArray, int yearLevelToSearch){ boolean found=false; for(int…
Q: Build the ItemToPurchase class with the following specifications Attributes item_name (string) item…
A: Attributes item_name (string)item_price (float)item_quantity (int) Default constructor Initializes…
Q: A furniture store specializes in office furniture and sells Office Chairs, Desks and Book Shelves.…
A: The ask is to build a program doing the following: - menu-driven options - Create classes for…
Q: Assume method testQuestion() is a method in the Purchase class. Assume the Purchase class has a…
A: Java Source Code: Purchase.java public class Purchase { private String name; private int…
Q: This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier…
A: NOTE - As per our guidelines we are supposed to do only one question, please repost other parts as a…
Q: Create a class Fraction with two integer final fields: numeratorand denominator. Its constructor…
A: Introduction of the Program: The Java program makes a Fraction class and this class has two member…
Q: Write a class Student with the following attributes (make sure the attributes are private using name…
A:
java
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images
- Hello, I am having trouble with this homework question Q1: Implement a class called Vehicle.a) A class named Vehicleb) Two private data members: brand (string), model (string), price (int).c) Accessors and Mutators function for brand, value, and price.Use following main() to test your class. int main(){Vehicle a;a.setBrand("BMW");a.setModel("X5");a.setPrice(60000);cout<<a.getBrand()<<endl; // print BMWcout<<a.getModel()<<endl; // print X5cout<<a.getPrice()<<endl; // print 60000}Question: 2Implement the design of the Chillox and Customer classes so that the following code generates the output below:print(f"It's been a good day!. \nToday, we have already served {Chillox.order_id} customers.")print("**************************************************")outlet1 = Chillox()print("1.==========================================")print("Burger Menu:")print(Chillox.menu)print("2.==========================================")outlet1.addBurger("Chicken Burger",180,"Chicken with Cheese",200)print("3.==========================================")print("Burger Menu:")print(Chillox.menu)print("4.==========================================")c1 = Customer("Samin")c1.order = "2xChicken Burger"outlet1.placeOrderof(c1)print("5.==========================================")outlet1.addBurger('Chicken Smoky BBQ Cheese',225)c2 = Customer("Rafi")c2.setOrder("2xChicken with Cheese,3xChicken Smoky BBQ…Assume method testQuestion() is a method in the Purchase class. Assume the Purchase class has a constructor that has parameters of name, groupCount, groupPrice, and numberBought. public Purchase testQuestion(Purchase p1, int newX) { newX = 20; this.setName("green beans"); p1.setName("corn"); Purchase p2 = new Purchase("broccoli", 5, 4.50, 10); return p2; } Referring to the above method, list the output that would be printed by Sysyem.out.println() when the following PurchaseDemo2 is executed. public class PurchaseDemo2 { public static void main(String[] args) { Purchase tomsPurchase = new Purchase("squash",4,3.50,6 ); Purchase jillsPurchase = new Purchase("carrot",8,1.99,4 ); Purchase billsPurchase;…
- 1. Create a class Employee with parameters name, id, designation, and basicSalary. Use appropriate datatypes and access specifiers. Use default constructor to create objects of employee. Write methods toset and get the values of parameters of employee. Write methods to find total salary of employee andto display the complete details of employee along with total salary. Create another class TestEmployeewhich creates array of n number of employees, uses appropriate set methods to set the values ofparameters of every employee. Display the details of each employee. (Total salary = basic salary + 80%of basic salary)Question: 2 Implement the design of the Purchaser and AarongProducts classes so that the following code generates the output below: #Write your code here p1 = Purchaser('Alex Light') print('1.===============================') print(p1) product1 = AarongProducts('Decor', 'Photo-Frame') print('2.===============================') print(product1) print('3.===============================') print(AarongProducts.products) print('4.===============================') AarongProducts.include_products('Souvenirs',['Brass-Flowervase 2170', 'Terracotta-Vase 3500']) print(f'Updated Item List:\n{AarongProducts.products}') print('5.===============================') product2 = AarongProducts('Souvenirs', 'Terracotta-Vase', 2) print(product2) print('6.===============================') p1.create_invoice(product1, product2) print('7.===============================') product3 = AarongProducts('Decor', 'Candles', 5) print(product3) print('8.===============================') product4 =…This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program). (1) Extend the ItemToPurchase class to contain a new attribute. item_description (string) - Set to "none" in default constructorImplement the following method for the ItemToPurchase class. print_item_description() - Prints item_description attribute for an ItemToPurchase object. Has an ItemToPurchase parameter. Ex. of print_item_description() output: Bottled Water: Deer Park, 12 oz. (2) Build the ShoppingCart class with the following data attributes and related methods. Note: Some can be method stubs (empty methods) initially, to be completed in later steps. Parameterized constructor which takes the customer name and date as parameters Attributescustomer_name (string) - Initialized in default constructor to "none"current_date (string) - Initialized in default constructor to "January 1, 2016"cart_items (list)Methodsadd_item()Adds an item to cart_items list. Has a parameter of…
- 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…this is the whole problem i did 1 to 3 im stuck at 4 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…This is for python class, so please answer in python 9.12 LAB: Product class In main.py define the Product class that will manage product inventory. Product class has three attributes: a product code, the product's price, and the number count of product in inventory. Implement the following methods: A constructor with 3 parameters that sets all 3 attributes to the value in the 3 parameters set_code(self, code) - set the product code (i.e. SKU234) to parameter code get_code(self) - return the product code set_price(self, price) - set the price to parameter price get_price(self) - return the price set_count(self, count) - set the number of items in inventory to parameter count get_count(self) - return the count add_inventory(self, amt) - increase inventory by parameter amt sell_inventory(self, amt) - decrease inventory by parameter amt
- Java Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A, B, C, D, E" is correct. Each question has one correct answer. Thank you. Part 1 - 7. Which is possibly a composite class? class Seed { ... }class Fruit { Seed s1 = new Seed(); }class Apple extends Fruits { ... }class Orange extends Apple { ... }class ApplePie { ApplePie a1 = new ApplePie(); } A. FruitB. AppleC. ApplePieD. OrangeE. Seed Part 2 - 8. Given the following code, the output is __. class Apple { int x = 5; }class Orange { int y = 6; }class Tangerine { int z = 7; } class Banana { Apple a1 = new Apple(); Orange o1 = new Orange(); Tangerine t1 = new Tangerine(); public int show() { return a1.x + o1.y + t1.z; }} public class Sample { public static void main(String[] args) { Banana b1 = new Banana(); System.out.println(b1.show()); }} A. 5B. 6C. 7D. 18E. 5+6+7Write a class that represents a player in a game. The player should have a name, password,experience points, an inventory array of four strings, and a location x,y. Your class shouldhave mutator and accessor methods for all variables. For example: setName(), getName(). Itshould have a suitable display method. Mutators and accessors should be public but allvariables should be private. To implement get inventory, use string * getInv(); Use the scoperesolution operator to implement larger methods such as display(). Use in class methods forshorter methods such as setName(), getName(). (in C++)Example:void setName(string name){this->name = name;}string *getInv();...string* player::getInv(){return inventory;}Note that in the above method setName “this->” is required for disambiguation. If writtenvoid setName(string n){name = n;}“this->” is not required.Write a test program that creates three players and displays them.Example Output:This program generates three player objects and…This program should be written in Java: Hamburger Joint: Hamburger ClassWrite a Hamburger class with the following six attributes: • bun - the type of bun the burger will be on • patties - the number of patties on the burger • cheese - whether or not the burger will have cheese • price - the price of the burger • toppings - an array of five toppings; it will need to start empty Write getters/setters for all attributes except the toppings array. Your constructor should create a single on white with no cheese and no toppings with a price of $2.99. Your class should include the following methods in this order, please: addCheese - this method has no parameters that adds cheese to the burger and increases the price by 75 cents superSizeIt - this method has no parameters and adds a patty to the burger and increases the price by 1.50 addToppings - this method would present the user with at least five toppings (your choice) stored in an array of String objects. If the user indicates the wants…