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

Have to create java program account management program using a MVC pattern.I kin

ID: 3554430 • Letter: H

Question

Have to create java program account management program using a MVC pattern.I kind of stuck it to do coding it. system suppose to ask me amount of deposit and widraw, and then I suppose to enter the amount of deposit and widraw money and updated it .

supposed print out id, name,updated balance.also make transfer option that balance transfer euro or yuan .I have to evaluate multiple people. but i dont have idea to evaluate multiple people account. please help me ~~

MODEL

package account.model;

public class AccountModel {

   private final double euro = 0.72;
   private final double yuan = 6.2;
   private String id;
   private String name;
   private double balance;

   public AccountModel(String id, String name, double balance) {
   super();
   this.id = id;
   this.name = name;
   this.balance = balance;
   }

   public String getId() {
   return id;
   }

   public void setId(String id) {
   this.id = id;
   }

   public String getName() {
   return name;
   }

   public void setName(String name) {
   this.name = name;
   }

   public double deposit(double amount)
   {
   balance= balance+amount;
   return balance;
   }
   public double withdraw(double amount)
   {
   balance= balance-amount;
   return balance;
   }
   public double editin_euro()
   {
   balance = balance * euro;
   return balance;
  
   }
   public double editin_yuan()
   {
   balance = balance / yuan;
   return balance;
   }
   public double getBalance()
   {
   return balance;
   }
   }

VIew

package account.model;

public class AccountView {

       public void Accountview(String id,String name, Double money) {
       System.out.println("ID: "+ id);
       System.out.println("Name: " + name);
       System.out.println("Balance: " + money);
       }
}

Control

package account.model;

public class AccountController {
   private AccountModel model;
   private AccountView view;
  
   public AccountController(AccountModel model, AccountView view) {
   this.model = model;
   this.view = view;
   }
  
   public void setaccountName(String name) {
   model.setName(name);
   }
  
   public String getaccountName() {
   return model.getName();
   }
  
   public void setaccountid(String id) {
   model.setId(id);
   }
  
   public String id() {
   return model.getId();
   }
   public Double balance()
   {
   return model.getBalance();
   }
   public void updateView() {
   view.Accountview(model.getName(), model.getId(),model.getBalance());
   }
   }

TEst

package account.model;

   public class MVCPatternTest {
       public static void main(String[] args) {
           AccountModel model = retriveaccountFromDB();
           AccountView view = new AccountView();
           AccountController controller = new AccountController(model, view);
           System.out.println("Initially... ======================");
           controller.updateView();
          
           System.out.println(" After Deposit... ======================");
           model.deposit(1234589.0);
           controller.updateView();

           System.out.println(" After Withdrawal... ======================");
           model.withdraw(12345.0);
           controller.updateView();

           System.out.println(" Balance in Euro... =======================");
           model.editin_euro();
           controller.updateView();

           System.out.println(" Balance in Yuan... ======================");
           model.editin_yuan();
           controller.updateView();

           }
          
           private static AccountModel retriveaccountFromDB() {
      
           AccountModel account= new AccountModel("1070","Strreter Angela M",34.4360);
           AccountModel account1=new AccountModel("1008","Iftkhar", 128.02);
           AccountModel account2=new AccountModel("1262","Meuer Benjamin",100);
           AccountModel account3=new AccountModel("1131","Komati Deepthi",223245.00);
           AccountModel account4= new AccountModel("1127","Lowell Daniel T", 0.5678);
           AccountModel account5=new AccountModel("1002","Cabello Israel Z",0.0);
           account.getBalance();
           account1.getBalance();
          
           return account1;
           }
           }

Explanation / Answer

import java.io.*; class Curr_acct //CURRENT ACCOUNT CLASS { final int max_limit=20; final int min_limit=1; final double min_bal=500; private String name[]=new String[20]; privateint accNo[]=newint[20]; private String accType[]=new String[20]; privatedouble balAmt[]=newdouble[20]; staticint totRec=0; //Intializing Methodpublicvoid initialize() { for(int i=0;imax_limit) { System.out.println(" Sorry we cannot admit you in our bank... "); permit=false; } if(permit = true) //Allows to create new entry { totRec++; // Incrementing Total Record System.out.println(" =====RECORDING NEW ENTRY====="); try{ accNo[totRec]=totRec; //Created AutoNumber to accNo so no invalid id occurs System.out.println("Account Number : "+accNo[totRec]); BufferedReader obj = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter Name : "); System.out.flush(); name[totRec]=obj.readLine(); accType[totRec]="Current Account"; System.out.println("Account Type : "+accType[totRec]); do{ System.out.print("Enter Initial Amount to be deposited : "); System.out.flush(); str=obj.readLine(); balAmt[totRec]=Double.parseDouble(str); }while(balAmt[totRec]= min_bal) { balAmt[acno]=checkamt; //Displaying Depsit Details System.out.println(" After Updation..."); System.out.println("Account Number : "+acno); System.out.println("Balance Amount : "+balAmt[acno]+" "); } else { System.out.println(" Your Balance has gone down and so penalty is calculated"); //Bank policy is to charge 20% on total difference of balAmt and min_bal to be maintain penalty=((min_bal - checkamt)*20)/100; balAmt[acno]=balAmt[acno]-(amt+penalty); System.out.println("Now your balance revels : "+balAmt[acno]+" "); } } } catch(Exception e) {} } } class Sav_acct //SAVING ACCOUNT CLASS { final int max_limit=20; final int min_limit=1; final double min_bal=500; private String name[]=new String[20]; privateint accNo[]=newint[20]; private String accType[]=new String[20]; privatedouble balAmt[]=newdouble[20]; staticint totRec=0; //Intializing Methodpublicvoid initialize() { for(int i=0;imax_limit) { System.out.println(" Sorry we cannot admit you in our bank... "); permit=false; } if(permit = true) //Allows to create new entry { totRec++; // Incrementing Total Record System.out.println(" =====RECORDING NEW ENTRY====="); try{ accNo[totRec]=totRec; //Created AutoNumber to accNo so no invalid id occurs System.out.println("Account Number : "+accNo[totRec]); BufferedReader obj = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter Name : "); System.out.flush(); name[totRec]=obj.readLine(); accType[totRec]="Saving Account"; System.out.println("Account Type : "+accType[totRec]); do{ System.out.print("Enter Initial Amount to be deposited : "); System.out.flush(); str=obj.readLine(); balAmt[totRec]=Double.parseDouble(str); }while(balAmt[totRec]= min_bal) { balAmt[acno]=checkamt; //Displaying Depsit Details System.out.println(" After Updation..."); System.out.println("Account Number : "+acno); System.out.println("Balance Amount : "+balAmt[acno]+" "); } else { System.out.println(" As per Bank Rule you should maintain minimum balance of Rs 500 "); } } } catch(Exception e) {} } } class Bank_improved { publicstaticvoid main(String args[]) { String str; int choice,check_acct=1,quit=0; choice=0; Curr_acct curr_obj = new Curr_acct(); Sav_acct sav_obj = new Sav_acct(); System.out.println(" =====WELLCOME TO BANK DEMO PROJECT===== "); while( quit!=1) { try{ BufferedReader obj = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Type 1 for Current Account and Any no for Saving Account : "); System.out.flush(); str=obj.readLine(); check_acct=Integer.parseInt(str); } catch(Exception e) {} if(check_acct==1) { do//For Current Account { System.out.println(" Choose Your Choices ..."); System.out.println("1) New Record Entry "); System.out.println("2) Display Record Details "); System.out.println("3) Deposit..."); System.out.println("4) Withdraw..."); System.out.println("5) Quit"); System.out.print("Enter your choice : "); System.out.flush(); try{ BufferedReader obj = new BufferedReader(new InputStreamReader(System.in)); str=obj.readLine(); choice=Integer.parseInt(str); switch(choice) { case 1 : //New Record Entry curr_obj.newEntry(); break; case 2 : //Displaying Record Details curr_obj.display(); break; case 3 : //Deposit... curr_obj.deposit(); break; case 4 : //Withdraw... curr_obj.withdraw(); break; case 5 : System.out.println(" .....Closing Current Account....."); break; default : System.out.println(" Invalid Choice "); } } catch(Exception e) {} }while(choice!=5); } else { do//For Saving Account { System.out.println("Choose Your Choices ..."); System.out.println("1) New Record Entry "); System.out.println("2) Display Record Details "); System.out.println("3) Deposit..."); System.out.println("4) Withdraw..."); System.out.println("5) Quit"); System.out.print("Enter your choice : "); System.out.flush(); try{ BufferedReader obj = new BufferedReader(new InputStreamReader(System.in)); str=obj.readLine(); choice=Integer.parseInt(str); switch(choice) { case 1 : //New Record Entry sav_obj.newEntry(); break; case 2 : //Displaying Record Details sav_obj.display(); break; case 3 : //Deposit... sav_obj.deposit(); break; case 4 : //Withdraw... sav_obj.withdraw(); break; case 5 : System.out.println(" .....Closing Saving Account....."); break; default : System.out.println(" Invalid Choice "); } } catch(Exception e) {} }while(choice!=5); } try{ BufferedReader obj = new BufferedReader(new InputStreamReader(System.in)); System.out.print(" Enter 1 for Exit : "); System.out.flush(); str=obj.readLine(); quit=Integer.parseInt(str); }catch (Exception e){} } } }
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