2. Complete the application below. public class CarApp { public static void main() { string color = blue; string model = C2021;i int speed 80; %3D // declare necessary object matching to the constructor definition // display the color and model on the screen // call the calspeed() method and display the new speed after calculat } }
Q: tity; private int capacity; private int seatsTaken; public DesertEvent(String eventName, String…
A: Here is a possible implementation of the Driver class (TestDesertEvent):
Q: Find the error in the following method definition:Look at the following method header:public static…
A: Answer is in step 2.
Q: // simulates a simple vending machine with operations to pur
A: The given coding practice requires you to create a VendingMachine object and perform operations…
Q: Language/Type: Java classes Write a class of objects named Date that remembers information about a…
A: Below I have provided a program for the given question. Also, I have attached a screenshot of the…
Q: Identify the correct statement for creating the object. Class Name: Student
A: new is the operator used to allocate memory for any instance
Q: 1. Add a field to the Hexagon.java class called side. It should be a double. 2. Write a no arguments…
A: Constructor is called when a instance of the class is created. It is used to initialize the object.…
Q: The following is Java pseudocode. For this exercise, you can assume the input function provides an…
A: The provided code is a Java program that consists of several methods, including test1, test2, input,…
Q: Java - Access Specifiers Create a class named Circle that has attributes radius, area, and…
A: formulas to calculate the circumference and area: c = 2πr and A = πr² .
Q: itialBalance; } public Account () { balance = 0; } public void deposit (double amount){ balance +=…
A: the code is an given below :
Q: public class Shape { Color fillColor; } public Shape() } fill Color = Color. RED; } public…
A: Lets talk about shape class(which is base class of Circle class): -->having attribute/data…
Q: The base class Pet has protected fields petName, and petAge. The derived class Cat extends the Pet…
A: The main() method of a program that makes instances of the Pet and Cat classes and prints their…
Q: /* TestCarSensor.java - program to test the CarSensor class. */ public class TestCarSensor { public…
A: Errors in CarSensor.java: The class had below errors: Data type was missing for data member: error,…
Q: public class Car { public void m1( { Sustem.Qut.printla("car 1"); } public void m2() { super.m1(); }…
A: answer is
Q: t the corners of a panel.
A: In this program the student asks us to add more designs like background images, font style, font…
Q: // Creates a Breakfast class // and instantiates an object // Displays Breakfast special information…
A: Given Program: using System;using static System.Console;using System.Globalization;class DebugNine2{…
Q: public class Area { /** * This getArea method returns the area of a circle. * * @param radius radius…
A: The code is written in Java and is implemented with object oriented approach. Since the functions in…
Q: public class Stadium extends baseStadium{ public int typeTicket; int floors; int seating;…
A: The code includes three classes: Stadium, ticket, and baseStadium, and one interface TicketService.…
Q: Neight(lb): " + shipWeightPounds); lat foofconte)" ELAT EEE CENTS). w. Special character legend…
A: I have answered below:
Q: import java.text.DecimalFormat; // Class representing a student public class Student { private…
A: 1. Create a class named Student with private fields: first (String), last (String), and gpa…
Q: package assignment; public class Circle2D2 { //data fields specifying the center of the circle…
A: Actually, program is executable software that runs on a computer.
Q: Practice with writing a program that contains three classes: Ship CruiseShip CargoShip Classes…
A: Solution - Programming language used: Java All solution steps are included in program code as…
Q: This lab will demonstrate how the toString() and equals() methods work when they a not overridden.…
A: for tostring()
Q: class Time { private int hour; private int minute; private int second;…
A: The JAVA code is given below with output screenshot
Q: Assume the following Window class has been defined: public class Window { private int width; private…
A: Define a class called Window with fields for width, height, xPos, and yPos. Define a constructor…
Q: Complete the missing line of code: public class Rectangle { private int width; private int height;…
A: The problem is based on parameterised constructors in C++ language.
Q: 1 a. is the amount the same, yes or no, why? public class CheckingAct { private String…
A: As per my company rule, I can solve the first three subheadings only. please post the remaining as a…
Q: 1. In the CheckingAccount class: a. Create one method for depositing. The deposit method should…
A: Step 1 : StartStep 2 : Declare all variablesStep 3 : create deposit, withdraw, display methodsStep 4…
Q: . Dummy GUI Application by Codechum Admin A GUI Application is an application that has a user…
A: First, implement another class called Checkbox which implements the Clickable interface which has…
Q: Consider the following class: 1 public class Student { 2 private int studentNumber; 3 private…
A: OOP or Object-Oriented Programming is a software model that is designed around data or objects…
Q: Question 1 public class Flat { private int noofRooms; private double area; private boolean seaView;…
A: public class Flat { private int noOfRooms; private double area; private boolean seaView;…
Q: Q1. amount the same, y, n, why? public class CheckingAct { private String actNum; private…
A: Dear Student, We valued your time. But as per guidelines, I can give answer only to the first…
Q: public class ItemToPurchase { private String itemName; private int itemPrice; private…
A: There was issue in taking the input and printing the details.
Q: The recipe for a homemade window cleaner is water, alcohol, ammonia, and dishwashing liquid.…
A: Required:
Q: I have the following code: public class Length { private int feet; private int inches; // Your code…
A: The given Java program is as follows: public class Length{private int feet;private int inches;//…
Q: CLASS NAME List the instance variables in the constructor. List the methods in the class. CLASS NAME…
A: As per the given question, we need to draw class diagram for the given class. Given Class name:…
Q: Given main(), define the Artist class (in file Artist.java) with constructors to initialize an…
A: 1// Artist.java 2public class Artist { 3 private String name; 4 private int birthYear; 5…
Q: Method 1 - displayTitle A method that creates a String object in memory to hold the text “Computer…
A: Computers.txt file: 10003000411250320043167539506418004300421600350032
Q: Given a base Plant class and a derived Flower class, complete main() to create an ArrayList called…
A: Algorithm:Create an empty ArrayList called myGarden to hold Plant or Flower objects.Initialize an…
Q: Public classTestMain { public static void main(String [ ] args) { Car myCar1,…
A: Solution: Given,
Q: Public Class SavingsAccount { float interest; float FixedDeposit; SeniorAccount(float…
A: A syntax error is the error in the program which is made typing mistakes by the user and logical…
Q: please use visual c# (Date Class) Create a class called Date that includes three pieces of…
A: In this question it is asked write a class called to Date to print a date in / format The code is…
Q: Hello I am in need help debugging this C# program.
A: Your Code - using static System.Console; -----------------Line1 class Debug5DA…
Step by step
Solved in 4 steps with 3 images
- UML for the following Code: public class ProductOrder { private int numBook = 0; private int numCD = 0; private int numDVD = 0; public ProductOrder(int numBook, int numCD, int numDVD){ this.numBook = numBook; this.numCD = numCD; this.numDVD = numDVD; } public int getBook(){ return numBook; } public void setBook(int numBook){ this.numBook = numBook; } public int getCD(){ return numCD; } public void setCD(int numCD){ this.numCD = numCD; } public int getDVD(){ return numDVD; } public void setDVD(int numDVD){ this.numDVD = numDVD; } public int getProductTotal(){ return getBook() + getCD() + getDVD(); } }public class LabProgram { public static void main(String args[]) { Course course = new Course(); String first; // first name String last; // last name double gpa; // grade point average first = "Henry"; last = "Cabot"; gpa = 3.5; course.addStudent(new Student(first, last, gpa)); // Add 1st student first = "Brenda"; last = "Stern"; gpa = 2.0; course.addStudent(new Student(first, last, gpa)); // Add 2nd student first = "Jane"; last = "Flynn"; gpa = 3.9; course.addStudent(new Student(first, last, gpa)); // Add 3rd student first = "Lynda"; last = "Robison"; gpa = 3.2; course.addStudent(new Student(first, last, gpa)); // Add 4th student course.printRoster(); } } // Class representing a student public class Student { private String first; // first name private String last; // last name private double gpa; // grade point average…I have the following code: public class Length{ private int feet; private int inches; Length() { feet = inches = 0; } Length(int newFeet, int newInches) { feet = newFeet; inches = newInches; } public int getFeet() { return feet; } public void setFeet(int newFeet) { feet = newFeet; } public int getInches() { return inches; } public void setInches(int newInches) { inches = newInches; } public void add(Length otherLength) { int newFeet = this.feet + otherLength.feet; int newInches = this.inches + otherLength.inches; if(newInches >= 12) { newFeet++; newInches -= 12; } this.setFeet(newFeet); this.setInches(newInches); } public Length subtract(Length otherLength) { if(this.feet > otherLength.feet) { int newFeet = feet - otherLength.feet; int newInches = inches - otherLength.inches;…
- Create an object called Circle. Declare the following integer variables for the object Circle, radius, diameter, ind pi is declared as double. Create the following for the Circle object: Implicit constructor (default constructor) Void method Calculate (double pi, int radius) to calculate the area of the Circle object. The method must include a system.out statement that displays the area value. Use the following formula to calculate area of the circle: Area = pi* (r* r) %3D our program includes a main class called Shape with a reference c1 to the Circle object. Pass the following alues to the object Circle: radius = 4 diameter = 8 pi = 3.14 nclude output statements to view the values passed to the object Circle.Objectives: Use Javadocs to document a class and methods Design and write a Java class Use fields (instance variables) Write multiple constructors Write accessor methods Write mutator methods Use the this keyword Use string concatenation Round floating point numbers (using Math.round()) Use a Scanner object Description ProduceItem class For this project, you get to design and write a ProduceItem class that stores a description, cost and weight as fields. Include both a constructor without any parameters and one with parameters for the description (String), cost (double) and weight (double) (in that order). For the constructor without parameters, set the description to an empty string, the cost to 0.0 and the weight to 0.0. Include appropriate accessor and mutator methods (and label them with comments including the terms "accessor" or "mutator"). So that the test cases compile, name the accessor methods: getDescription() getCost() getWeight() Additionally, name the mutator methods:…// This class discounts prices by 10% public class DebugFour4 { public static void main(String args[]) { final double DISCOUNT_RATE = 0.90; int price = 100; double price2 = 100.00; tenPercentOff(price DISCOUNT_RATE); tenPercentOff(price2 DISCOUNT_RATE); } public static void tenPercentOff(int p, final double DISCOUNT_RATE) { double newPrice = p * DISCOUNT_RATE; System.out.println("Ten percent off " + p); System.out.println(" New price is " + newPrice); } public static void tenPercentOff(double p, final double DISCOUNT_RATE) { double newPrice = p * DISCOUNT_RATE; System.out.println"Ten percent off " + p); System.out.println(" New price is " + newprice); } }
- public class Author2 {3 private String name;4 private int numberOfAwards;5 private boolean guildMember;6 private String[] bestsellers;78 public String Author()9 {10 name = "Grace Random";11 numberOfAwards = 0;12 guildMember = false;13 bestsellers = {"Minority Report", "Ubik", "The Man in the HighCastle"};14 }1516 public void setName(String n)17 {18 name = n;19 }20 public String getName()21 {22 return name;23 }2425 public void winsAPulitzer()26 {27 System.out.println(name + " gave a wonderful speech!");28 }29 } 1. This class includes a constructor that begins on line 8; however, it contains an error. Describe the error. 2. Rewrite the constructor header on line 8 with the error identied in part c of this question corrected. 3. Demonstrate how you might overload the constructor for this class. Write only the header. 4. Write a line of Java code to create an instance (object) of this class. Name it someAuthor. 5. Write a line of code to demonstrate how you would use the someAuthor object…Java script. class Chameleon { static colorChange(newColor) { this.newColor = newColor; return this.newColor; } constructor({ newColor = 'green' } = {}) { this.newColor = newColor; } } const freddie = new Chameleon({ newColor: 'purple' }); console.log(freddie.colorChange('orange'));.Using JAVASCRIPT write an object prototype for a Person that has a name and age, has a printInfo method, and also has a method that increments the persons age by 1 each time the method is called. Create two people using the 'new' keyword, and print both of their infos and increment one persons age by 3 years. Use an arrow function for both methods */ // Create our Person Prototype // Use an arrow to create the printInfo method // Create another arrow function for the addAge method that takes a single parameter // Adding to the age
- public class DesertEvent { private static int eventCount = 0; private String barCode; private String location; private String eventName; private String eventType; private int quantity; private int capacity; private int seatsTaken; public DesertEvent(String eventName, String eventType) { this(eventName, eventType, 0); calcMaximumSeats(eventType); generateBarCode(); } public DesertEvent(String eventName, String eventType, int capacity) { this.eventName = eventName; this.eventType = eventType; this.capacity = capacity; generateBarCode(); eventCount++; } public String getBarCode() { return barCode; } public String getLocation() { return location; } public String getEventName() { return eventName; } public String getEventType() { return eventType; } public int getQuantity() { return quantity; } public void setQuantity(int quantity) { this.quantity = quantity; } public int getCapacity() { return capacity; } public void setCapacity(int capacity) { this.capacity = capacity;…class IndexItem { public: virtual int count() = 0; virtual void display()= 0; };class Book : public IndexItem { private: string title; string author; public: Book(string title, string author): title(title), author(author){} virtual int count(){ return 1; } virtual void display(){ /* YOU DO NOT NEED TO IMPLEMENT THIS FUNCTION */ } };class Category: public IndexItem { private: /* fill in the private member variables for the Category class below */ ? int count; public: Category(string name, string code): name(name), code(code){} /* Implement the count function below. Consider the use of the function as depicted in main() */ ? /* Implement the add function which fills the category with contents below. Consider the use of the function as depicted in main() */ ? virtualvoiddisplay(){ /* YOU DO NOT NEED TO IMPLEMENT THIS FUNCTION */ } };// Simulates a simple car with operations to drive and check the odometer.public class SimpleCar { // Number of miles driven private int miles; public SimpleCar(){ miles = 0; } public void drive(int dist){ miles = miles + dist; } public void reverse(int dist){ miles = miles - dist; } public int getOdometer(){ return miles; } public void honkHorn(){ System.out.println("beep beep"); } public void report(){ System.out.println("Car has driven: " + miles + " miles"); } }