Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

•create a new savings account object (for choice 2). •ask the user to enter an i

ID: 3758028 • Letter: #

Question

•create a new savings account object (for choice 2).

•ask the user to enter an initial balance which should be greater than 50. If the entered amount is less than 50, the program will ask the user to enter another amount. This continues until an amount greater than 50 is entered.

•Set the balance of the savings account object by calling the setBalance() method.

•Ask the user to deposit an amount. Deposit that amount and display the balance of the account.

/**
* Super class Account
*
*/
public class Account {
   /**
   * balance of the account
   */
   protected double balance;
   /**
   * constructor
   */
   public Account() {
       balance = 0;
   }
   /**
   * set the balance
   * @param amt balance
   */
   public void setBalance(double amt) {
       balance += amt;
   }
   /**
   * deposit to account
   * @param amt
   */

   public void deposit(double amt) {
       balance += amt;
   }
   /**
   * withdraw from account
   * @param amt
   */

   public void withDraw(double amt) {
       balance -= amt;
   }

   /**
   * display the account balance
   */
   public void displayBalance() {
       System.out.println("Balance - " + balance);
   }
}

----------------------------------------

import java.util.Scanner;

public class testAccount {

   /**
   * A simple test function to test Account and SavingsAccount class
   * @param args
   */
   public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       System.out.println("Welcome. Which account do you want to create? 1. Normal 2. Savings");
       System.out.print("Enter choice: ");
       int choice = sc.nextInt();
       Account acct = null;
       if (choice == 1) {
           acct = new Account();
           System.out.println("New normal account created.");
           acct.displayBalance();
       } else if (choice == 2) {
           //Here write your code as required in the Question          

       }
       //Deposit money to account here
       acct.displayBalance();

   }
}

CSC 2310 Homework HW 6 and Lab program will ask the user to enter another amount. This continues until an amount greater than 50 is entered Dr. Xiaolin Hu Set the balance of the savings account object by calling the HW6 & Lab: setBalance() method Ask the user to deposit an amount. Deposit that amount and display the balance of the account. Objective Lab: To learn basic inheritance using simple super class and sub class HW: To learn inheritance using graphics Part I:( Lab Programming) Due bv: End of Lab Turn in the SavingsAccount.java and testAccount.java Below is an illustration of how the program works: Welcome. Which account do you want to create? . You are given the class Account with predefined methods for bank account. It already has methods to display the balance and methods to withdraw and deposit some amount 2. Savings 1. Normal Enter choice: 2 Enter initial balance: ($50) -20 Balance should be greater than 50 Enter initial balance: ($50) -70 Balance 70.0 Enter amount to deposit: 100 Balance - 180.0 . You need to create a subclass called SavingsAccount. Your SavingsAccount class should override the deposit method, so that when a user deposits an amount in the savings account, the bank will add additional 10% to the amount . You are given a testAccount class which asks the user what account it want to create. In the testAccount class, add java code to do the following things in a sequential order: create a new savings account object (for choice 2) Part II: HW6 . ask the user to enter an initial balance which should be Deadlines as posted in d2l file Deadlines greater than 50. If the entered amount is less than 50, the

Explanation / Answer

package mani;
import java.util.Scanner;
public class testAccount {
/**
* A simple test function to test Account and SavingsAccount class
* @param args
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Welcome. Which account do you want to create? 1. Normal 2. Savings");
System.out.print("Enter choice: ");
int choice = sc.nextInt();
double iBal;
Account acct = null;
if (choice == 1) {
acct = new Account();
System.out.println("New normal account created.");
acct.displayBalance();
} else if (choice == 2) {
   acct=new SavingsAccount();
   System.out.println("New savings account created.");
   while(true){
       System.out.print("Enter initial balance: (>$50) - ");
       iBal=sc.nextDouble();
       if(iBal<50){
           System.out.println("Balance should be greater than 50");
       }else{
           acct.setBalance(iBal);
           break;
       }
       acct.displayBalance();
   }
   System.out.print("Enter amount to deposit: ");
   double bal=sc.nextDouble();
   acct.deposit(bal);
//Here write your code as required in the Question
}
  
acct.displayBalance();
}
}

package mani;
public class Account {
/**
* balance of the account
*/
protected double balance;
/**
* constructor
*/
public Account() {
balance = 0;
}
/**
* set the balance
* @param amt balance
*/
public void setBalance(double amt) {
balance += amt;
}
/**
* deposit to account
* @param amt
*/
public void deposit(double amt) {
balance += amt;
}
/**
* withdraw from account
* @param amt
*/
public void withDraw(double amt) {
balance -= amt;
}
/**
* display the account balance
*/
public void displayBalance() {
System.out.println("Balance - " + balance);
}
}

package mani;

public class SavingsAccount extends Account {
public void deposit(double amt){
   balance+=amt;
   balance+=(amt*0.1);
}
  
  
}