Question

LAB1 PART 1 FOR THE DATA TYPE CLASS: If you do not have UML of class...

LAB1 PART 1
FOR THE DATA TYPE CLASS:
If you do not have UML of class Account_yourLastName, you should do that first

Basesd on the UML, provide the code of data type class Account_yourLastName to hold the information of an account with account number (String), name (String), balance (double), with no-argument constructor, parameter constructor

Also, define some methods to handle the tasks: open account, check current balance, deposit, withdraw, and print monthly statement. At the end of each task we have the output as below:

Task OPEN ACCOUNT

For example: account number is 1567794657, name Mary Lane, and start balance is 500

-display the output:

OPEN NEW ACCOUNT – JAMES SMITH BANK

Account Number: Name:
Balance:

1567794657 Mary Lane 500.0

Task CHECK CURENT BALANCE - Display the output:CHECK CURRENT BALANCE – JAMES SMITH BANK

Account Number: Name:
Current Balance:

1567794657 Mary Lane 500.0

Task DEPOSIT -If deposit amount is 200 to above account, display the output:DEPOSIT – JAMES SMITH BANK

Account Number: Name:
Balance:
Deposit amount: New Balance:

1567794657 Mary Lane 500.0

200.0 700.0

Task WITHDRAW -If withdraw amount is 300, display the output:WITHDRAW – JAMES SMITH BANK

Account Number: Name:
Balance:

Withdraw: New Balance:

1567794657 Mary Lane 700.0 300.0

400.0

Task PRINT MONTHLY STATEMENT - dIsplay the following output: MONTHLY STATEMENT – JAMES SMITH BANK

Account Number: Name:
End Balance:

1567794657 Mary Lane

700.0

FOR THE DRIVER CLASS: provide the pseudo-code or flowchart then write the code for the BankService_yourLastName to provide the application of a bank service. First, provide the following menu of tasks:

BankService_Smith.java

MAIN MENU – JAMES SMITH BANK

  1. Open new account

  2. Check current balance

  3. Deposit

  4. Withdraw

  5. Print monthly statement

0. Exit

If users select other task before opening account then, the program will display message box:“You should open account first”

Task 1: Open new account:
-After reading all information of the account entered from the keyboard to create an account-Create the object of the class Account
-then display the output by calling the method Create New Account

Task 2: Check current balance
-call the method Check Current Balance from data type class to display the output

Task 3: Deposit
-ask users for depoit amount, call the method deposit from data type class to display the output

Task 4: Withdraw
-ask users for withdraw amount, call the method withdraw of class Account_yourLastName

Task 5: Print monthly statement -print the monthly statement

EXIT
When users exit display the message box:

“Thank you. The application is terminating..”

Requirement:
-You have to change Smith to your last name
-Change James Smith to your full name
-Add the file name as the first comment line at the top of each class
-Get the output of the task Monthly Statement then paste it in the file with pseudo-code -write the comment on each part in both classes

COMPILE AND RUN THE PART1 TO GET THE OUTPUT

LAB1 PART 2

FOR THE DATA TYPYE CLASSES:
-Add to the project of part 2, the class Account_yourLastName (from part1)
-Add to the project of part 2 two more classes: class CheckingAccount_yourLastName and class SavingAccount_yourLastName. These classes have the same data members and methods with class Account_yourLastName but each of them has more data members and each method has a little difference.

class CheckingAccount_yourLastName: add data member serviceFee (float), minumumAmount = 20.0 class SavingAccount_yourLastName: add data member interestRate(float), minimumAmount = 100.0

Task OPEN ACCOUNT

-if money amount to open account is less than minimum amount then display the message:“Invalid open account amount. Account cannot be created”

Otherwise display the message:

OPEN NEW ACCOUNT – JAMES SMITH BANK

OR

Account Number: Name:
Balance:
Type:

1567794657 Mary Lane 500.0 Checking Account

OPEN NEW ACCOUNT – JAMES SMITH BANK

Account Number: Name:
Balance:
Type:

1567794657 Mary Lane 500.0 Saving Account

Task CHECK CURENT BALANCE - Display the output:CHECK CURRENT BALANCE – JAMES SMITH BANK

Account Number: Name:
Current Balance: Type:

1567794657 Mary Lane 500.0 Checking Account

OR
CHECK CURRENT BALANCE – JAMES SMITH BANK

Account Number: Name:
Current Balance: Type:

1567794657 Mary Lane 500.0 Saving Account

Task DEPOSIT -If deposit amount is 200 to above account, display the output:DEPOSIT – JAMES SMITH BANK

OR

Checking Account WITHDRAW – JAMES SMITH BANK

Account Number:
Name:
Balance:
Deposit amount:
New Balance:
Type: Checking Account

OR
DEPOSIT – JAMES SMITH BANK

Account Number: Name:
Balance:

Withdraw: New Balance: Type:

1567794657 Mary Lane 700.0

690.0 - denied 700.0

Account Number: Name:
Balance:

Withdraw: New Balance: Type:

1567794657 Mary Lane 700.0

600.0 - denied 700.0

Saving Account

1567794657 Mary Lane 500.0

Task PRINT MONTHLY STATEMENT - dIsplay the following output: MONTHLY STATEMENT – JAMES SMITH BANK

Account Number: Name:
Balance: Severvice Fee New Balance Type:

1567794657 Mary Lane

700.0 10.0 690.0

Checking Account

200.0 700.0

Account Number:
Name:
Balance:
Deposit amount:
New Balance:
Type: Saving Account

Task WITHDRAW -If withdraw amount makes the new balance less than minimum amount then Display denied message:

WITHDRAW – JAMES SMITH BANK

1567794657 Mary Lane 500.0

200.0 700.0

OR
MONTHLY STATEMENT – JAMES SMITH BANK

Account Number: Name:
Balance:
Interest Rate: Interest Amount: New Balance

Type:

1567794657 Mary Lane 700.00

0.05%

0.35 700.35 Saving Account

FOR THE DRIVER CLASS (main)

Display the menu as you did in part 1
However: For each task, you should handle for either Checking Accout or Saving account

Remember:
-The file name should be the first comment line at the top of class
-write the comment on each parts of both classes
-get the output pictures of the task Monthly Statement, paste them after the pseudo code.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//account file

//lab1task 1

//please change bank name based on the specified condtionPlease select options 1.open Account 2.check Current balance 3.Deposit 4.withdraw 5.print Mont hly statement 6.exit Please en
import java.util.*;
public class Account
{
static int accno=1567794657,end=0;
static float amount=500;
//accno is given assuming it needs to be generated by the bank itself
static String name,bankName="James Smith Bank";
Account(String accName,int amt){
amount=amt;
name=accName;
//update name and amount
}
Account(){
  
}
void openAccount(){
System.out.println("Opened new Acount In"+bankName);
System.out.println("Account Number"+accno);
System.out.println("Name :"+name);
System.out.println("Balance"+amount);
System.out.println(accno+" "+name+" "+amount);
}
static void withdraw(float amt){
if(amt>amount){
//if balance is low
System.out.println("You do not have sufficient balance");
return;
}
amount-=amt;
System.out.println("withdraw "+bankName);
System.out.println("Account Number"+accno);
System.out.println("Name :"+name);
System.out.println("Balance"+amount);
System.out.println(accno+" "+name+" "+(amount+amt)+" "+amt+" "+amount);
  
}
static void monthlyStatement(){
System.out.println("Monthly Statement "+bankName);
System.out.println("Account Number"+accno);
System.out.println("Name :"+name);
System.out.println("Balance"+amount);
System.out.println(accno+" "+name+" "+amount);
}
   public static void main(String[] args) {
   int start=0;
   while(end==0){
       System.out.println("Please select options 1.open Account 2.check Current balance 3.Deposit 4.withdraw 5.print MOnthly statement 6.exit");
       Scanner scanner=new Scanner(System.in);
       int n=scanner.nextInt();
       DataType dataObj=new DataType();
       if(start==0 && n!=1){
       //if trying to do anything other than opening Account stop that and
       //create an account
       System.out.println("You should open open Account first");
       System.out.println("Press 1 to open account 2 to exit");
       int k=scanner.nextInt();
       if(k==1){
       System.out.println("Please enter Name");
       String name=scanner.next();
       System.out.println("Enter amount ");
       int amt=scanner.nextInt();
       //creating object to the account class
       Account acc=new Account(name,amt);
       acc.openAccount();
       //updating that account is created
       start=1;
       }
       else{
       System.out.println("Thank you. The application is terminating..");
       // updating terminating condition
       end=1;
       }
       }
       else{
       if(n==1){
       System.out.println("Please enter Name");
       String name=scanner.next();
       System.out.println("Enter amount ");
       int amt=scanner.nextInt();
       Account acc=new Account(name,amt);
       acc.openAccount();
       start=1;
       }else if(n==2){
       dataObj.checkCurrentBalance();
       }else if(n==3){
       System.out.println("Enter Amount to deposit");
       int amt=scanner.nextInt();
       dataObj.deposit(amt);
       }else if(n==4){
       System.out.println("Enter Amount to withdraw");
       int amt=scanner.nextInt();
       withdraw(amt);
       }else if(n==5){
       monthlyStatement();
       }else if(n==6){
       System.out.println("Thank you. The application is terminating..");
       end=1;
       }else{
       System.out.println("Enter correct CHoice");
       }
       }
   }
      
   }
}
class DataType extends Account{
public void checkCurrentBalance(){
System.out.println("Check balance - "+super.bankName);
System.out.println("Account Number"+super.accno);
System.out.println("Name :"+super.name);
System.out.println("Balance"+super.amount);
System.out.println(super.accno+" "+super.name+" "+super.amount);
}
public void deposit(int amt){
super.amount+=amt;
System.out.println("Deposit -"+super.bankName);
System.out.println("Account Number"+super.accno);
System.out.println("Name :"+super.name);
System.out.println("Balance"+super.amount);
System.out.println(super.accno+" "+super.name+" "+(super.amount-amt)+" "+amt+" "+super.amount);
  
}
  
}

//lab1 task 2

//saving account and checking account classes all the methods for the both classes are kept //separatelyV pul 100 Deposit -James Smith Bank Account Number1567794657 Name :dsvhbvh Balance200.0 Type- CheckingAccount 1567794657 dsvh
import java.util.*;
public class Main
{
  
//accno is given assuming it needs to be generated by the bank itself
static int type,end=0;
Main(){
  
}
  
  
   public static void main(String[] args) {
   int start=0;
   while(end==0){
       System.out.println("Please select options 1.open Account 2.check Current balance 3.Deposit 4.withdraw 5.print MOnthly statement 6.exit");
       Scanner scanner=new Scanner(System.in);
       int n=scanner.nextInt();
       if(start==0 && n!=1){
       //if trying to do anything other than opening Account stop that and
       //create an account
       System.out.println("You should open open Account first");
       System.out.println("Press 1 to open account 2 to exit");
       int k=scanner.nextInt();
       if(k==1){
       System.out.println("Please enter Name");
       String name=scanner.next();
       System.out.println("Enter amount ");
       int amt=scanner.nextInt();
       System.out.println("Enter type of Account 1.Checking Account 2.Savings Accoutn");
       //to get type of account
       type=scanner.nextInt();
       if(type==1){
      
       CheckingAccount check=new CheckingAccount(name,amt);
       check.openAccount();
       }else if(type==2){
         
       SavingAccount saving=new SavingAccount(name,amt);
       saving.openAccount();
       }
      
       start=1;
       }
       else{
       System.out.println("Thank you. The application is terminating..");
       // updating terminating condition
       end=1;
       }
       }
       else{
       CheckingAccount checkAcc=new CheckingAccount();
       SavingAccount savAcc=new SavingAccount();
       if(n==1){
       System.out.println("Please enter Name");
       String name=scanner.next();
       System.out.println("Enter amount ");
       int amt=scanner.nextInt();
       System.out.println("Enter type of Account 1.Checking Account 2.Savings Accoutn");
       //to get type of account
       type=scanner.nextInt();
       if(type==1){
      
       CheckingAccount check=new CheckingAccount(name,amt);
       check.openAccount();
       }else if(type==2){
         
       SavingAccount saving=new SavingAccount(name,amt);
       saving.openAccount();
       }
      
       start=1;
       }else if(n==2){
       if(type==1)
       checkAcc.checkCurrentBalance();
       else
       savAcc.checkCurrentBalance();
       }else if(n==3){
       System.out.println("Enter Amount to deposit");
       int amt=scanner.nextInt();
      
       if(type==1)
       checkAcc.deposit(amt);
       else
       savAcc.deposit(amt);
       }else if(n==4){
       System.out.println("Enter Amount to withdraw");
       int amt=scanner.nextInt();
       if(type==1)
       checkAcc.withdraw(amt);
       else
       savAcc.withdraw(amt);
       }else if(n==5){
      
       if(type==1)
       checkAcc.monthlyStatement();
       else
       savAcc.monthlyStatement();
       }else if(n==6){
       System.out.println("Thank you. The application is terminating..");
       end=1;
       }else{
       System.out.println("Enter correct CHoice");
       }
       }
   }
      
   }
}
class CheckingAccount extends Main{
static int accno=1567794657;
static float amount=500;
float serviceFee,minimumAmount=20.0f;
static String name,bankName="James Smith Bank";
CheckingAccount(String accName,int amt){
amount=amt;
name=accName;
//update name and amount
}
CheckingAccount(){
  
}
void openAccount(){
if(amount<minimumAmount){
System.out.println("Invalid open account amount. Account cannot be created");
name="";
amount=0;
accno=0;
return;
}
accno=1567794657;
System.out.println("Opened new Acount In"+bankName);
System.out.println("Account Number"+accno);
System.out.println("Name :"+name);
System.out.println("Balance"+amount);
System.out.println("Type- CheckingAccount");
System.out.println(accno+" "+name+" "+amount+" CheckingAccount");
}
void withdraw(float amt){
if(amt>amount){
//if balance is low
System.out.println("You do not have sufficient balance");
  
return;
}
amount-=amt;
System.out.println("withdraw "+bankName);
System.out.println("Account Number"+accno);
System.out.println("Name :"+name);
System.out.println("Balance"+amount);
System.out.println("Type- CheckingAccount");
System.out.println(accno+" "+name+" "+(amount+amt)+" "+amt+" "+amount+" CheckingAccount");
  
}
void monthlyStatement(){
System.out.println("Monthly Statement "+bankName);
System.out.println("Account Number"+accno);
System.out.println("Name :"+name);
System.out.println("Balance"+amount);
System.out.println("Type- CheckingAccount");
System.out.println(accno+" "+name+" "+amount+" CheckingAccount");
}
void checkCurrentBalance(){
System.out.println("Check balance - "+bankName);
System.out.println("Account Number"+accno);
System.out.println("Name :"+name);
System.out.println("Balance"+amount);
System.out.println("Type- CheckingAccount");
System.out.println(accno+" "+name+" "+amount+"CheckingAccount");
}
void deposit(int amt){
amount+=amt;
System.out.println("Deposit -"+bankName);
System.out.println("Account Number"+accno);
System.out.println("Name :"+name);
System.out.println("Balance"+amount);
System.out.println("Type- CheckingAccount");
System.out.println(accno+" "+name+" "+(amount-amt)+" "+amt+" "+amount+" CheckingAccount");
  
}
  
}
class SavingAccount extends Main{
static int accno=1567794657;
static float amount=500;
float interestRate,minimumAmount=100.0f;
static String name,bankName="James Smith Bank";
SavingAccount(String accName,int amt){
amount=amt;
name=accName;
//update name and amount
}
SavingAccount(){
  
}
void deposit(int amt){
amount+=amt;
System.out.println("Deposit -"+bankName);
System.out.println("Account Number"+accno);
System.out.println("Name :"+name);
System.out.println("Balance"+amount);
System.out.println("Type- SavingAccount");
System.out.println(accno+" "+name+" "+(amount-amt)+" "+amt+" "+amount+"SavingAccount");
  
}
void checkCurrentBalance(){
System.out.println("Check balance - "+bankName);
System.out.println("Account Number"+accno);
System.out.println("Name :"+name);
System.out.println("Balance"+amount);
System.out.println("Type- SavingAccount");
System.out.println(accno+" "+name+" "+amount+" SavingAccount");
}

void openAccount(){
if(amount<minimumAmount){
System.out.println("Invalid open account amount. Account cannot be created");
name="";
amount=0;
accno=0;
return;
}
accno=1567794657;
System.out.println("Opened new Acount In"+bankName);
System.out.println("Account Number"+accno);
System.out.println("Name :"+name);
System.out.println("Balance"+amount);
System.out.println("Type- SavingAccount");
System.out.println(accno+" "+name+" "+amount+"SavingAccount");
}
void withdraw(float amt){
if(amt>amount){
//if balance is low
System.out.println("You do not have sufficient balance");
return;
}
amount-=amt;
System.out.println("withdraw "+bankName);
System.out.println("Account Number"+accno);
System.out.println("Name :"+name);
System.out.println("Balance"+amount);
System.out.println("Type- SavingAccount");
System.out.println(accno+" "+name+" "+(amount+amt)+" "+amt+" "+amount+"SavingAccount");
  
}
void monthlyStatement(){
System.out.println("Monthly Statement "+bankName);
System.out.println("Account Number"+accno);
System.out.println("Name :"+name);
System.out.println("Balance"+amount);
System.out.println("Type- SavingAccount");
System.out.println(accno+" "+name+" "+amount+"SavingAccount");
}
  
}

Add a comment
Know the answer?
Add Answer to:
LAB1 PART 1 FOR THE DATA TYPE CLASS: If you do not have UML of class...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Java: DATA TYPE CLASS Create one data type class Account_yourLastName that hold the information of...

    In Java: DATA TYPE CLASS Create one data type class Account_yourLastName that hold the information of an account such as accountNumber (String), name (String), address (String), balance (float), interestRate(float) and beside the no-argument constructor, parameterized constructor, the class has method openNewAccount, method checkCurrentBalance, method deposit, method withdrawal, method changeInterestRate REQUIREMENT - DRIVER CLASS Provide the application for the Bank Service that first displays the following menu to allow users to select one task to work on. After finishing one task,...

  • *Step1: -Create UML of data type classes: reuse from lab3 for class Account, CheckingAccount and SavingAccount...

    *Step1: -Create UML of data type classes: reuse from lab3 for class Account, CheckingAccount and SavingAccount -Read the requirement of each part; write the pseudo-code in a word document by listing the step by step what you suppose to do in main() and then save it with the name as Lab4_pseudoCode_yourLastName *Step2: -start editor eClipse, create the project→project name: FA2019_LAB4PART1_yourLastName(part1) OR FA2019_LAB4PART2_yourLastName (part2) -add data type classes (You can use these classes from lab3) Account_yourLastName.java CheckingAccount_yourLastName.java SavingAccount_yourLastName.java -Add data structure...

  • c++ please    Define the class bankAccount to implement the basic properties of a bank account....

    c++ please    Define the class bankAccount to implement the basic properties of a bank account. An object of this class should store the following data: Account holder’s name (string), account number (int), account type (string, checking/saving), balance (double), and interest rate (double). (Store interest rate as a decimal number.) Add appropriate member func- tions to manipulate an object. Use a static member in the class to automatically assign account numbers. Also declare an array of 10 compo- nents of...

  • Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment...

    Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment also aims at creating a C++ project to handle multiple files (one header file and two .cpp files) at the same time. Remember to follow documentation and variable name guidelines. Create a C++ project to implement a simplified banking system. Your bank is small, so it can have a maximum of 100 accounts. Use an array of pointers to objects for this. However, your...

  • In this, you will create a bank account management system according to the following specifications: BankAccount...

    In this, you will create a bank account management system according to the following specifications: BankAccount Abstract Class contains the following constructors and functions: BankAccount(name, balance): a constructor that creates a new account with a name and starting balance. getBalance(): a function that returns the balance of a specific account. deposit(amount): abstract function to be implemented in both Checking and SavingAccount classes. withdraw(amount): abstract function to be implemented in both Checking and SavingAccount classes. messageTo Client (message): used to print...

  • Need some help with this C++ code. Please screenshot the code if possible. Purpose: Demonstrate the...

    Need some help with this C++ code. Please screenshot the code if possible. Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment also aims at creating a C++ project to handle multiple files (one header file and two .cpp files) at the same time. Remember to follow documentation and variable name guidelines. Create a C++ project to implement a simplified banking system. Your bank is small, so it can have a maximum of...

  • TASK 1 Create a new class called CheckingAccount that extends BankAccount. It should contain a static...

    TASK 1 Create a new class called CheckingAccount that extends BankAccount. It should contain a static constant FEE that represents the cost of clearing onecheck. Set it equal to 15 cents. Write a constructor that takes a name and an initial amount as parameters. Itshould call the constructor for the superclass. It should initializeaccountNumber to be the current value in accountNumber concatenatedwith -10 (All checking accounts at this bank are identified by the extension -10). There can be only one...

  • Define the class bankAccount to implement the basic properties of a bank account. An object of...

    Define the class bankAccount to implement the basic properties of a bank account. An object of this class should store the following data: Account holder’s name (string), account number (int), account type (string, checking/saving), balance (double), and interest rate (double). (Store interest rate as a decimal number.) Add appropriate member functions to manipulate an object. Use a static member in the class to automatically assign account numbers. Also, declare an array of 10 components of type bankAccount to process up...

  • how do i fix the errors? 1) Write an Account class that models a bank account...

    how do i fix the errors? 1) Write an Account class that models a bank account with the following data and operations. Data - The identity number for the account, which is an integer - The balance in the account Operations - create an account with a given identity number and initial balance .return the identity number - return the current balance - set the balance to some amount deposit some amount into the account, increasing the balance - withdraw...

  • Implement a class Portfolio. This class has two objects, checking and savings, of the type BankAccount....

    Implement a class Portfolio. This class has two objects, checking and savings, of the type BankAccount. Implement four methods: • public void deposit(double amount, String account) • public void withdraw(double amount, String account) • public void transfer(double amount, String account) • public double getBalance(String account) Here the account string is "S" or "C". For the deposit or withdrawal, it indicates which account is affected. For a transfer, it indicates the account from which the money is taken; the money is...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT