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

Define a Java class named Account. Your class should have instance data correspo

ID: 3884949 • Letter: D

Question

Define a Java class named Account. Your class should have instance data corresponding to the account number and account type, as well as the individual's name and account balance. In addition to the standard accessor and mutator methods, your class should also contain two methods: deposit - deposits an amount into the account withdraw - withdraws an amount from the account Ensure that validation exists in those two methods, ensuring that the user does not deposit a negative amount into the account, or withdraws an amount over the available balance. Write a main method which simply tests a series of withdraws and deposits. Save your solution in the file named Account.java.

Explanation / Answer

import java.util.Scanner;

class bankInternal {
    int acno;
   String acc_type;
    float bal=0;
    Scanner get = new Scanner(System.in);
    bankInternal()
    {
        System.out.println("Enter Account Number:");
        acno = get.nextInt();
       System.out.println("Enter Account type");
       acc_type=get.next();
    }
    void deposit()
    {
        float amount;
      
        System.out.println("Enter Amount to be Deposited:");
        amount = get.nextFloat();
       if(amount>0){
        bal = bal+amount;
        System.out.println("Account Number:"+acno+" Account Type:"+acc_type+" Deposited! Account Balance is "+bal);
       }
       else{System.out.println("Amount should be more than 0");}
    }
    void withdraw()
    {
        float amount;
        System.out.println("Enter Amount to be Withdrawn:");
        amount = get.nextFloat();
        if(amount<bal)
        {
            bal = bal-amount;
            System.out.println("Account Number:"+acno+" Account Type:"+acc_type+" Amount Withdrawn!! Available Balance: "+bal);
        }
        else
        {
            System.out.println("Insufficient funds!! Account Number:"+acno+" Account Type:"+acc_type+" Available Balance:"+bal);
        }
    }
}
public class HelloWorld {
    public static void main(String[] args)
    {
        Scanner get = new Scanner(System.in);
       int repeate=1;
       while(repeate!=0){
        System.out.println("1.Deposit 2.Withdrawl ");
        int choice=get.nextInt();
        bankInternal myObj = new bankInternal();
        if(choice==1){
        myObj.deposit();}
        else if(choice==2){
        myObj.withdraw();}      
        else{System.out.println("Invalid choice");}
       System.out.println("do you want to continue 0:exit 1:Continue ");
       repeate=get.nextInt();
       }
    }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote