Menu

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

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

public class BankAccount later // private instance variables--filled in // Constructors public BankAccount () // body--filled1 2 3 /** A class to test the BankAccount class. */ public class BankAccountTester Tests the methods of the BankAccount class

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. public class BankAccount later // private instance variables–filled in // Constructors public BankAccount () // body–filled in later public BankAccount (double initialBalance) // body–filled in later // Methods public void deposit (double amount) // body–filled in later public void withdraw (double amount) // body–filled in later public double getBalance () // body–filled in later Return 0; } 1 2 3 /** A class to test the BankAccount class. */ public class BankAccountTester Tests the methods of the BankAccount class. @param args not used public static void main(String[] args) BankAccount harrysChecking = new BankAccount(); harrysChecking.deposit (2000); harrysChecking withdraw (500); System.out.println (harrysChecking.getBalance()); System.out.println(“Expected: 1500”); 18 } 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.
public class BankAccount later // private instance variables–filled in // Constructors public BankAccount () // body–filled in later public BankAccount (double initialBalance) // body–filled in later // Methods public void deposit (double amount) // body–filled in later public void withdraw (double amount) // body–filled in later public double getBalance () // body–filled in later Return 0; }
1 2 3 /** A class to test the BankAccount class. */ public class BankAccountTester Tests the methods of the BankAccount class. @param args not used public static void main(String[] args) BankAccount harrysChecking = new BankAccount(); harrysChecking.deposit (2000); harrysChecking withdraw (500); System.out.println (harrysChecking.getBalance()); System.out.println(“Expected: 1500”); 18 }

Expert Answer


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

OR