The BankAccount class models changes to the balance of a person’s savings account.
Q: You are part of a team writing classes for the different game objects in a video game. You need to…
A: public class Human { //is base class //declaring instance variables private String name;…
Q: Design a LandTract class that has two fields (i.e. instance variables): one for the tract’s length(a…
A: public class LandTract { double length; double width; public LandTract(double length, double width)…
Q: Create a UML diagram to help design the class baby. class Baby{ //data members private String…
A: The required Unified Modeling Language (UML) class diagram for the class “Baby” is as follows,
Q: name class: import java.io.*; import java.util.*; public class Name { public Name(String last,…
A: The Program is written in Java Language.
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: please complete the code class CheckingAct { private int balance; public void processDeposit(int…
A: Here, we have given the java code with the class Checking Act. We need to complete the code by…
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: public class Base { public void PrintName() { System.out.println("Base"); static void PrintClass() {…
A: The full code for the first problem is :public class Base { public void PrintName() {…
Q: /** Represents a car. */ public class Car // TODO: Inherit from Vehicle { // Do NOT add any…
A: Description: In the constructor of Car class, call the superclass constructor with the purchasePrice…
Q: Java programming language I need the two classes ( the testing class and the class with the…
A: We can merge both the classes in one (testing and method class) . We can use main method the…
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: 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: 26. Assume the declaration of Exercise 24. A. Write the staternents that derive the class dummyClass…
A: Dear Student, For inheritance we use the syntax - Class B extends A Here class B is the derived…
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: //PLEASE CORRECT MY MISTAKES, THANK YOU public class Person { private String personID; private…
A: As per the question, solution is mentioned below:
Q: Defining Classes Write and document the definition for the Money class. The Money class represents…
A: Purpose of the program: This program would create the Money.java class with two pre-defined…
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: Assignment:The BankAccount class models an account of a customer. A BankAccount has the…
A: Program: Filename: “BankAccount.java” // Import the required package import java.util.Date; // Class…
Q: class Player { protected: string name; double weight; double height; public:…
A: Note: since your question contain multiple subparts but we can answer only 3sub-parts at a time…
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: ven the following class definition: class employee { public: employee(); employee(string,…
A: The code has given below
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: What's the depth of inheritance for mobile phones? How many methods are overridden/overloaded…
A: As per our guidelines we are supposed to answer only 1st three parts. kindly repost the remaining…
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: 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 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: 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: Please code in python Create a program with two classes – the person class and the student The…
A:
Q: public class Course { private String courseNumber, courseTitle; public Course() {…
A: SOLUTION - So, in this code, you are getting a Space error. This is because of these two lines -…
Q: Find the error(s) in the following class definition: public class Circle { private double radius;…
A: Ans: The error in the following class definition is that in the get and the set function the get…
- The BankAccount class models changes to the balance of a person’s savings account.
public class BankAccount
{ public BankAccount(String name, double initBal)
public double getBalance()
public String getName()
public void deposit(double amount)
public void withdraw(double amount)
public void transferTo(BankAccount otherAcct, double amt)
public boolean equals(Object other)
private String acctName;
private double balance;
}
- Provide the code for the transferTo(…)
- Briefly explain why there is no setBalance() method in this class.
Step by step
Solved in 2 steps with 1 images
- // 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 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,…
- 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…Consider the following class public class Ketchup extends Food implements Tasty{ public String brand; private Snack snack; } Select ALL that are correct based this class. Ketchup is a Food Ketchup is a Tasty Ketchup is an Object Ketchup is a Snack Food is a Tasty Snack is a Tasty Food is a SnackFinish the constructor for the KickBall class. public class Ball { public double diameter; public Ball(double diam) { diameter = diam; public class KickBall extends Ball private Color ballColor; public KickBall(double diam, Color ballColor) {