Menu

(Solved) : Activity 1 Modify Bankaccount Class Adding Following Features 1 Every Bankaccount Object S Q44019880 . . .

using java to write, show me the output

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

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: Strings = “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: Car myHybrid = new Car(50); myHybrid.addGas (20); myHybrid.drive(100); double gasLeft = myHybrid.getGas InTank(); // 50 miles per gallon // Tank 20 gallons // Drive 100 miles // Get gas remaining in tank 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. Show transcribed image text 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: Strings = “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: Car myHybrid = new Car(50); myHybrid.addGas (20); myHybrid.drive(100); double gasLeft = myHybrid.getGas InTank(); // 50 miles per gallon // Tank 20 gallons // Drive 100 miles // Get gas remaining in tank 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.

Expert Answer


Answer to Activity 1. Modify the BankAccount class by adding the following features: 1- Every BankAccount object should store the …

OR