Question: Using the following Account and AccountTest as a guide, create a class (Account) with the needed functionality to implement in the AccountTest application. Sample: Account
Using the following Account and AccountTest as a guide, create a class (Account) with the needed functionality to implement in the AccountTest application.
Sample:
Account #: 1001
First Name: John
Last Name: Doe
Balance: $100.99
Account #: 1002
First Name: Mary
Last Name: Smith
Balance: $25.15
// Name: // Date:
import java.util.Scanner;
public class AccountTest { public static void main(String[] args) { Scanner input = new Scanner(System.in); // create Account objects Account account1 = new Account("John", "Doe", 1001, 100.99); Account account2 = new Account("Mary", "Smith", 1002, 25.15);
// display data System.out.printf("%nAccount #: %d%nFirst Name: %s%nLast Name: %s%nBalance: $%.2f%n", account1.getAccountNumber(), account1.getFirstName(), account1.getLastName(), account1.getBalance() );
// display data System.out.printf("%nAccount #: %d%nFirst Name: %s%nLast Name: %s%nBalance: $%.2f%n%n", account2.getAccountNumber(), account2.getFirstName(), account2.getLastName(), account2.getBalance() ); } // end main } // end class AccountTest
// Name: // Date:
public class Account { // TO DO: Declare Account Variables // constructor to initialize public Account(String firstName, String lastName, int accountNumber, double balance) { // TO DO: Define Constructor } // TO DO: Define get and set methods } // end class Account
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
