Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Activity 1. Modify the BankAccount class by adding the following features: 1- Every BankAccount object should store the name of the account holder. 2- Every

image text in transcribed

Activity 1. Modify the BankAccount class by adding the following features: 1- Every BankAccount object should store the name of the account holder. 2- Every BankAccount object should store the type of the account, which could be Saving or Checking. 3- There should be an additional constructor for initializing not only the initial balance of the new account but initializing account's holder name and type as well. 4 Methods for retrieving the account's holder name, and type. Also try to see if you can provide a method, by which you can withdraw some money from one BankAccount object and deposit it into another BankAccount object. Note that you should provide only one single method to perform this task that changes the state (balance) of two BankAccount objects. Activity 2. What would be the outputs of the following code snippet: String s = "Hello"; System.out.println(s.toUppercase()); String t = s; System.out.println(t); What do we learn from this example about the String class and its methods? Activity 3. Implement a class Car with the following properties. A car has a certain fuel efficiency, measured in liters/km, and a certain amount of fuel in the gas tank. The efficiency is specified in the constructor, and the initial fuel level is 0. Supply a method drive that simulates driving the car for a certain distance, reducing the amount of gasoline in the fuel tank. Also, supply methods getGasInTank, returning the current amount of gasoline in the fuel tank, and addGas, to add gasoline to the fuel tank, Sample usages of the Car class would be: // 50 miles per gallon // Tank 20 gallons // Drive 100 miles // Get gas remaining in tank Car mytybrid = new Car(50); myHybrid.addGas (20); myHybrid.drive(100); double gasleft = myHybrid.getGasInTank(); You may assume that the drive method is never called with a distance that consumes more than the available gas. After implementation the class, supply a CarTester class that tests all methods

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions