What is printed? public class Puppy { private int puppyAge; private String puppyName; Puppy(String name){ puppyName = name ;} public void setAge( int age ) { puppyAge = ++age; } public int getAge(){return puppyAge; } %3D public class TestPuppy{ public static void main(String []args) { Puppy myPuppy = new Puppy( "tommy" ); myPuppy.setAge( 2 ); System.out.print("Puppy's age is :" + myPuppy.getAge( )); System.out.print(" Name chosen is :" + myPuppy.puppyNname ); O Puppy's age is : 2 Name chosen is : tommy Puppy's age is : 3 Name chosen is : tommy Syntax Error Run Time Error
Q: please make it run using static System.Console; class GreenvilleRevenue { static void Main()…
A: Given Code:- using static System.Console; class GreenvilleRevenue { static void Main() {…
Q: Student Name: 8) Consider the following ciass definitions. public class LibraryID{ private String…
A: To compare `LibraryID` objects `one` and `two` inside the if statement, you would just call the…
Q: class Animal { public String toString() { return "Animal"; } public String f() { return "Animal f";…
A: The solution is provided in the next step.
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: Prompt Below is the definition for the Receipt class: public class Receipt { private String[]…
A: Hello studentGreetingsThe Receipt class presented here encapsulates the logic for managing a list of…
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: public class Student { private String name; private String major; privatedoublegpa;…
A: To fix the main method so it does not print out the memory location, you need to modify the way the…
Q: itialBalance; } public Account () { balance = 0; } public void deposit (double amount){ balance +=…
A: the code is an given below :
Q: JAVA Language Caesar Shift Question: Modify the Caesar class so that it will allow various…
A: Algorithm: Caesar Cipher1. Create an abstract class called Cipher. a. Define an abstract method…
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: public class Number { private int num; public Number(int n) { num = n; } /*…
A: 1. Import the Scanner class for user input.2. Define a `LabProgram` class.3. Inside the `LabProgram`…
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: What is the output of the code on the right?
A: Java is an object oriented programming language.
Q: 58. How many finalizers can a class have? - a. C. 2 d. Any number b. 1 59. Which of the following…
A: Note: This is a multiple-question-based problem. As per company guidelines, only the first question…
Q: public class Car { public void m1( { Sustem.Qut.printla("car 1"); } public void m2() { super.m1(); }…
A: answer is
Q: public class FoodItem { private String name; private double fat; private double carbs;…
A: 1public class FoodItem { 2 private String name; 3 private double fat; 4 private double carbs;…
Q: e int a; e static int y = 10; numClass(int newX) X; } void set(int newX) X; y+=a; } public static…
A: Explanation: Here, first the value of y of one object is set to 30. Then, on object two the set…
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: PlayerRoster.java:139: error: class, interface, or enum expected import java.util.Scanner;…
A: We need to rectify the errors in the given Java code.
Q: Modify the Cage class to implement Comparable.The definition of the Comparable interface can be…
A: Actually, java is a object oriented programming language. It is a platform independent.
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: class Clock { public: Clock() : hourValue_(0), minuteValue_(0), secondValue_(0) {};…
A: The objective of the question is to override the ShowTime() function of the base class 'Clock'…
Q: This lab will demonstrate how the toString() and equals() methods work when they a not overridden.…
A: for tostring()
Q: Please draw the UML for this code package lap; import java.util.Date; class Covenant { private…
A: The UML code is given in the below step
Q: class Time { private int hour; private int minute; private int second;…
A: The JAVA code is given below with output screenshot
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: 5 Select one or more options from the list cat.getAge(); O cat.getName(); cat.getColor();…
A: Explanation: I have created a main class to for compiling this program, The methods that are in…
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: class temporary { public: void set(string, double, double); void print(); double manipulate();…
A: Algorithm:Include necessary libraries:Include the required C++ libraries for input and output…
Q: public class Person { private String personID; private String firstName; private String lastName;…
A: Your code is also correct but I have provided more efficient code below.
Q: class Artist{StringsArtist(const std::string& name="",int…
A: The objective of the question is to implement a function in the Singer class that checks if the…
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: class Artist{StringsArtist(const std::string& name="",int…
A: The objective of the question is to implement a function in C++ that combines two Singer objects…
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: public class SidePlot { public static String PLOT_CHAR = "*"; public static void main(String[] args)…
A: I have provided JAVA CODE along with CODE SCREENSHOT and OUTPUT SCREENSHOT------
Q: Subclass toString should call include super.toString(); re-submit these codes. public class…
A: Program Modifications:Add the super.toString() call with the other print statements in the…
Q: UML for the following Code: public class ProductOrder { private int numBook = 0; private…
A: Answer: We have written UML diagram for given following code
Q: Complete the Course class by implementing the printRoster() method, which outputs a list of all…
A: Create a Course object representing a course.Initialize variables first, last, and gpa to store…
Q: Given main() and a base Book class, define a derived class called Encyclopedia with member methods…
A: As per the given information, I need to provide the code for Encyclopedia class.Algorithm for…
Q: It is supposed to output the following: Expected output [15' 0"] [20' 6"] [17' 4"] [16' 4"] [17'…
A: public class Length { private int feet; private int inches; Length() { feet = inches = 0; }…
Q: // This class discounts prices by 10% public class DebugFour4 { public static void main(String…
A: In this problem, to compute new price, we need to subtract discount amount from old price. The…
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- public class Car { private int modelYear; // TODO: Declare purchasePrice field (int) private int currentValue; public void setModelYear(int userYear){ modelYear = userYear; } public int getModelYear() { return modelYear; } // TODO: Define setPurchasePrice() method // TODO: Define getPurchasePrice() method public void calcCurrentValue(int currentYear) { double depreciationRate = 0.15; int carAge = currentYear - modelYear; // Car depreciation formula currentValue = (int) Math.round(purchasePrice * Math.pow((1 - depreciationRate), carAge)); } // TODO: Define printInfo() method to output modelYear, purchasePrice, and currentValue } import java.util.Scanner;import java.lang.Math; public class CarValue { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); Car myCar = new Car(); int userYear = scnr.nextInt(); int userPrice = scnr.nextInt(); int…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…class Bug { private final int orgPosition = 0; private int currentPosition; private boolean direction; public Bug() { direction = true; currentPosition = orgPosition; } public void move() { if (direction) { ++currentPosition; } else { --currentPosition; } } public void turn() { direction = !direction; } public int getPosition() { return currentPosition; } public boolean getDirection() { return direction; } public String toString() { StringBuffer sb = new StringBuffer(); sb.append("Position = " + currentPosition + ", Direction = "); sb.append(direction ? "RIGHT" : "LEFT"); return sb.toString(); } } -------------------------------------TestDriver.java------------------------------------- import java.util.Scanner; class TestDriver { public static void main(String args[]) { Scanner input = new Scanner(System.in); Bug b…
- public class Cat extends Pet { private String breed; public void setBreed(String userBreed) { breed = userBreed; } public String getBreed() { return breed; }} public class Pet { protected String name; protected int age; public void setName(String userName) { name = userName; } public String getName() { return name; } public void setAge(int userAge) { age = userAge; } public int getAge() { return age; } public void printInfo() { System.out.println("Pet Information: "); System.out.println(" Name: " + name); System.out.println(" Age: " + age); } } import java.util.Scanner; public class PetInformation { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); // create a generic Pet and a Cat Pet myPet = new Pet(); Cat myCat = new Cat(); // declare variables for pet and cat info String petName, catName, catBreed; int petAge,…public static class Lab2{public static void Main(){int idNum;double payRate, hours, grossPay;string firstName, lastName;// prompt the user to enter employee's first nameConsole.Write("Enter employee's first name => ");firstName = Console.ReadLine();// prompt the user to enter employee's last nameConsole.Write("Enter employee's last name => ");lastName = Console.ReadLine()// prompt the user to enter a six digit employee numberConsole.Write("Enter a six digit employee's ID => ");idNum = Convert.ToInt32(Console.ReadLine());// prompt the user to enter the number of hours employeeworkedConsole.Write("Enter the number of hours employee worked =>");// prompt the user to enter the employee's hourly pay rateconsole.Write("Enter employee's hourly pay rate: ");payRate = Convert.ToDouble(Console.ReadLine());// calculate gross paygrossPay = hours * payRate;// output resultsConsole.WriteLine("Employee {0} {1}, (ID: {2}) earned {3}",firstName, lastName, idNum,…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 Course { private String courseNumber; private String courseName; private int creditHrs; public Course (String number, String name, int creditHrs){ this.courseNumber = number; this.courseName = name; this.creditHrs = creditHrs; } public String getNumber() { return courseNumber; } public String getName() { return courseName; } public int getCreditHrs() { return creditHrs; } public void setCourseNumber(String courseNumber) { this.courseNumber = courseNumber; } public void setCourseName(String courseName) { this.courseName = courseName; } public void setCreditHrs(int creditHrs) { this.creditHrs = creditHrs; }}class Student { private String firstName; private String lastName; private String gender; private String phoneNumber; private String email; private String jNumber; protected ArrayList courseList; public String getFullName() {…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"); } }
- public class Person { private String personID; private String firstName; private String lastName; private String birthDate; private String address; public Person(){ personID = ""; firstName = ""; lastName = ""; birthDate = ""; address = ""; } public Person(String id, String first, String last, String birth, String add){ setPerson(id,first,last,birth,add); } public void setPerson(String id, String first, String last, String birth, String add){ personID = id; firstName = first; lastName = last; birthDate = birth; address = add; } public String getFirstName(){ return firstName; } public String getLastName(){ return lastName; } public String getBirthdate(){ return birthDate; } public String getAddress(){ return address; } public void print(){ System.out.print("\nPerson ID = " + personID); System.out.print("\nFirst Name = " +firstName); System.out.print("\nLast Name = " +lastName); System.out.print("\nBirth Date = " +birthDate); System.out.print("\nAddress = " +address); } public String…this is my retail item code: //Import statements public class RetailItem { private String description; private int units; private double price; public RetailItem() { } public RetailItem(String x, int y, double z) { description = x; units = y; price = z; } public RetailItem(RetailItem i) { } public void setDescription(String x) { description = x; } public void setPrice(double z) { price = z; } void setUnits(int y) { units = y; } public int getUnits() { return units; } public String getDescription() { return description; } public double getPrice() { return price; } // Main class public static void main(String[] args) { String str = "Shirt"; RetailItem r1 = new RetailItem("Jacket", 12,…public class Cylinder { public void smoothen() { } } } public abstract class Vessel implements Steerable { private Engine e; } System.out.println("Smoothening.."); public Engine getEngine() { return e; } public void setEngine (Engine e) { this.e = e; } public abstract void turnOn(); public class Engine { private Cylinder [] y; private int cyls = 1; static final int maxCylinders = 12; public void addCylinder (Cylinder y) { if (cylsSEE MORE QUESTIONS