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

Needing help please Step 1: Create a class named Account with data fields for an

ID: 3564107 • Letter: N

Question

Needing help please

Step 1:

Create a class named Account with data fields for an account number, payment amount and balance as well as the appropriate set and get methods. Include a constructor method that contains no arguments. Set the account number equal to 23456, payment amount to 250 and the balance to 3600. Write the appropriate comments and save the program. Compile and correct any errors.

Step 2:

Create a program named TestAccount to demonstrate that each method created in BankAccount works correctly. Make sure to create the output so that one blank line will print between the output created in Steps 4, 6, and 8. Write the appropriate comments and save the program. Compile and run the program.

Step 3:

Create an additional overloaded constructor for the Account class. This constructor should receive one argument for the account number and two assigned values for the payment amount and the balance. Make the three numbers different from the ones used in Step 1. Write the appropriate comments and save the program. Compile and correct any errors.

Step 4:

Add any needed statements to the TestAccount class to ensure that the overloaded constructor works correctly. Make sure to create the output so that one blank line will print between the output created in Steps 4, 6, and 8. Write the appropriate comments and save the program. Compile and run the program.

Step 5:

Create an additional overloaded constructor for the Account class. This constructor should receive two arguments, one for the account number and one for payment amount, and one assigned values for the balance. Make the three numbers different from the ones used in Step 3. Write the appropriate comments and save the program. Compile and correct any errors.

Step 6:

Add any needed statements to the TestAccount class to ensure that the overloaded constructor works correctly. Make sure to create the output so that one blank line will print between the output created in Steps 4, 6, and 8. Write the appropriate comments and save the program. Compile and run the program.

Step 7:

Create an additional overloaded constructor for the Account class. This constructor should receive three arguments for the account number, the payment amount, and the balance and no assigned values. Make the three numbers different from the ones used in Step 5. Write the appropriate comments and save the program. Compile and correct any errors.

Step 8:

Add any needed statements to the TestAccount class to ensure that the overloaded constructor works correctly. Make sure to create the output so that one blank line will print between the output created in Steps 4, 6, and 8. Write the appropriate comments and save the program. Compile and run the program.

Explanation / Answer

step1:

//Account class

public class Account

{

     //local declarations

     private long accountNumber;

     private double paymentAmount;

     private double balance;

   

     //constructor with No parameters

     public Account()

     {

          //assign the variables with the specified values

          accountNumber = 23456;

          paymentAmount = 250;

          balance = 3600;       

     }

   

     //getAccountNumber() returns the accountNumber

     public long getAccountNumber()

     {

          return accountNumber;

     }

   

     //setAccountNumber() assigns the accountNumber

     public void setAccountNumber(long accoutNumber)

     {

          this.accountNumber = accoutNumber;

     }

   

     //getPaymentAmount() returns the paymentAmount

     public double getPaymentAmount()

     {

          return paymentAmount;

     }

   

     //setPaymentAmount() assigns the paymentAmount

     public void setPaymentAmount(double paymentAmount)

     {

          this.paymentAmount = paymentAmount;

     }

   

     //getBalance() returns the balance

     public double getBalance()

     {

          return balance;

     }

   

     //setBalance assigns the balance

     public void setBalance(double balance)

     {

          this.balance = balance;

     }

}

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

step 2:

//class Tester1

public class Tester1

{

     //main method

     public static void main(String arg[])

     {

          //create an instance to Account class

         //Constructor with No arguments will be invoked

          Account account1 = new Account();

          //display the Account number

          System.out.println("Account Number is : "+account1.getAccountNumber());

          //display the payment amount

          System.out.println("Payment Amount is : "+account1.getPaymentAmount());

          //display the balance

          System.out.println("Balance is : "+account1.getBalance());            

     }

}

Sample Output:

Account Number is : 23456

Payment Amount is : 250.0

Balance is : 3600.0

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

step 3:

//Account class

public class Account

{

     //local declarations

     private long accountNumber;

     private double paymentAmount;

     private double balance;

   

     //constructor with No parameters

     public Account()

     {

          //assign the variables with the specified values

          accountNumber = 23456;

          paymentAmount = 250;

          balance = 3600;       

     }

   

   //overloaded constructor with a sinlge argument accountNumber

     public Account(long accountNumber)

     {

          //assign the variables with the specified values

          this.accountNumber = accountNumber;

          paymentAmount = 100;

          balance = 2700;       

     }

     //getAccountNumber() returns the accountNumber

     public long getAccountNumber()

     {

          return accountNumber;

     }

   

     //setAccountNumber() assigns the accountNumber

     public void setAccountNumber(long accoutNumber)

     {

          this.accountNumber = accoutNumber;

     }

   

     //getPaymentAmount() returns the paymentAmount

     public double getPaymentAmount()

     {

          return paymentAmount;

     }

   

     //setPaymentAmount() assigns the paymentAmount

     public void setPaymentAmount(double paymentAmount)

     {

          this.paymentAmount = paymentAmount;

     }

   

     //getBalance() returns the balance

     public double getBalance()

     {

          return balance;

     }

   

     //setBalance assigns the balance

     public void setBalance(double balance)

     {

          this.balance = balance;

     }

}

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

step 4:

//class Tester1

public class Tester1

{

//main method

public static void main(String arg[])

{

//create an instance to Account class

Account account1 = new Account();

//display the Account number

System.out.println("Account Number is : " +account1.getAccountNumber());

//display the payment amount

System.out.println("Payment Amount is : "+account1.getPaymentAmount());

//display the balance

System.out.println("Balance is : "+account1.getBalance());

   //Constructor with single argument will be invoked

Account account2 = new Account(12390);

//display the Account number

System.out.println("Account Number is : "+account2.getAccountNumber());

//display the payment amount

System.out.println("Payment Amount is : "+account2.getPaymentAmount());

//display the balance

System.out.println("Balance is : " +account2.getBalance());

     }

}

Sample Output:

Account Number is : 23456

Payment Amount is : 250.0

Balance is : 3600.0

Account Number is : 23456

Payment Amount is : 250.0

Balance is : 3600.0

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

step 5:

//Account class

class Account

{

     //local declarations

     private long accountNumber;

     private double paymentAmount;

     private double balance;

   

     //constructor with No parameters

     public Account()

     {

          //assign the variables with the specified values

          accountNumber = 23456;

          paymentAmount = 250;

          balance = 3600;       

     }

     //constructor with single argument

     public Account(long accountNumber)

     {

          //assign the variables with the specified values

          this.accountNumber = accountNumber;

          paymentAmount = 100;

          balance = 2700;       

     }

          //constructor with twoarguments

     public Account(long accountNumber, double paymentAmount)

     {

          //assign the variables with the specified values

          this.accountNumber = accountNumber;

          this.paymentAmount = paymentAmount;

          balance = 4500;       

     }

     //getAccountNumber() returns the accountNumber

     public long getAccountNumber()

     {

          return accountNumber;

     }

   

     //setAccountNumber() assigns the accountNumber

     public void setAccountNumber(long accoutNumber)

     {

          this.accountNumber = accoutNumber;

     }

   

     //getPaymentAmount() returns the paymentAmount

     public double getPaymentAmount()

     {

          return paymentAmount;

     }

   

     //setPaymentAmount() assigns the paymentAmount

     public void setPaymentAmount(double paymentAmount)

     {

          this.paymentAmount = paymentAmount;

     }

   

     //getBalance() returns the balance

     public double getBalance()

     {

          return balance;

     }

   

     //setBalance assigns the balance

     public void setBalance(double balance)

     {

          this.balance = balance;

     }

}

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

step 6:

//class Tester1

public class Tester1

{

     //main method

     public static void main(String arg[])

     {

          //create an instance to Account class

          Account account1 = new Account();

          //display the Account number

          System.out.println("Account Number is : " +account1.getAccountNumber());

          //display the payment amount

          System.out.println("Payment Amount is : "+account1.getPaymentAmount());

          //display the balance

          System.out.println("Balance is : "+account1.getBalance());   

            //Constructor with single arguments will be invoked

          Account account2 = new Account(12390);

          //display the Account number

          System.out.println("Account Number is : "+account2.getAccountNumber());

          //display the payment amount

          System.out.println("Payment Amount is : "+account2.getPaymentAmount());

          //display the balance

          System.out.println("Balance is : " +account2.getBalance());   

            //Constructor with two arguments will be invoked

          Account account3 = new Account(12390, 2000);

          //display the Account number

          System.out.println("Account Number is : "+account3.getAccountNumber());

          //display the payment amount

          System.out.println("Payment Amount is : " +account3.getPaymentAmount());

          //display the balance

          System.out.println("Balance is : "+account3.getBalance());   

     }

}

Sample output:

Account Number is : 23456

Payment Amount is : 250.0

Balance is : 3600.0

Account Number is : 12390

Payment Amount is : 100.0

Balance is : 2700.0

Account Number is : 12390

Payment Amount is : 2000.0

Balance is : 4500.0

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

step 7:

//Account class

class Account

{

     //local declarations

     private long accountNumber;

     private double paymentAmount;

     private double balance;

   

     //constructor with No parameters

     public Account()

     {

          //assign the variables with the specified values

          accountNumber = 23456;

          paymentAmount = 250;

          balance = 3600;       

     }

         //constructor with single argument

     public Account(long accountNumber)

     {

          //assign the variables with the specified values

          this.accountNumber = accountNumber;

          paymentAmount = 100;

          balance = 2700;       

     }

      //constructor with two arguments

     public Account(long accountNumber, double paymentAmount)

     {

          //assign the variables with the specified values

          this.accountNumber = accountNumber;

          this.paymentAmount = paymentAmount;

          balance = 4500;       

     }

          //constructor with three arguments

     public Account(long accountNumber, double paymentAmount,double balance)

     {

          //assign the variables with the specified values

          this.accountNumber = accountNumber;

          this.paymentAmount = paymentAmount;

          this.balance = balance;    

     }

   

     //getAccountNumber() returns the accountNumber

     public long getAccountNumber()

     {

          return accountNumber;

     }

   

     //setAccountNumber() assigns the accountNumber

     public void setAccountNumber(long accoutNumber)

     {

          this.accountNumber = accoutNumber;

     }

   

     //getPaymentAmount() returns the paymentAmount

     public double getPaymentAmount()

     {

          return paymentAmount;

     }

   

     //setPaymentAmount() assigns the paymentAmount

     public void setPaymentAmount(double paymentAmount)

     {

          this.paymentAmount = paymentAmount;

     }

   

     //getBalance() returns the balance

     public double getBalance()

     {

          return balance;

     }   

     //setBalance assigns the balance

     public void setBalance(double balance)

     {

          this.balance = balance;

     }

}

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

step 8:

//class Tester1

public class Tester1

{

     //main method

     public static void main(String arg[])

     {

          //create an instance to Account class

          Account account1 = new Account();

          //display the Account number

          System.out.println("Account Number is : "+account1.getAccountNumber());

          //display the payment amount

          System.out.println("Payment Amount is : "+account1.getPaymentAmount());

          //display the balance

          System.out.println("Balance is : "+account1.getBalance());

            //Constructor with single argument will be invoked

          Account account2 = new Account(12980);

          //display the Account number

          System.out.println("Account Number is : " +account2.getAccountNumber());

          //display the payment amount

          System.out.println("Payment Amount is : "+account2.getPaymentAmount());

          //display the balance

          System.out.println("Balance is : "+account2.getBalance());       

         //Constructor with two arguments will be invoked    

          Account account3 = new Account(12470, 2000);

          //display the Account number

          System.out.println("Account Number is : " +account3.getAccountNumber());

          //display the payment amount

          System.out.println("Payment Amount is : " +account3.getPaymentAmount());

          //display the balance

          System.out.println("Balance is : "+account3.getBalance());     

            //Constructor with three arguments will be invoked

          Account account4 = new Account(12390, 6000,100);

          //display the Account number

          System.out.println("Account Number is : " +account4.getAccountNumber());

          //display the payment amount

          System.out.println("Payment Amount is : "+account4.getPaymentAmount());

          //display the balance

          System.out.println("Balance is : "+account4.getBalance());

     }

}

Output:

Account Number is : 23456

Payment Amount is : 250.0

Balance is : 3600.0

Account Number is : 12980

Payment Amount is : 100.0

Balance is : 2700.0

Account Number is : 12470

Payment Amount is : 2000.0

Balance is : 4500.0

Account Number is : 12390

Payment Amount is : 6000.0

Balance is : 100.0

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