Question: CIS 254 Spring 2020 CIS254 Assignment 6 Classes. Objects, Methods and Strings Due Date: Saturday February 15, 2020 (by midnight) Weight: 2 points Objectives: Simple

 CIS 254 Spring 2020 CIS254 Assignment 6 Classes. Objects, Methods and
Strings Due Date: Saturday February 15, 2020 (by midnight) Weight: 2 points
Objectives: Simple Classes and objects What to submit Consider the Account class

CIS 254 Spring 2020 CIS254 Assignment 6 Classes. Objects, Methods and Strings Due Date: Saturday February 15, 2020 (by midnight) Weight: 2 points Objectives: Simple Classes and objects What to submit Consider the Account class given on slide 44 and the AccountTest class given on slides 46-47 of the "3 Classes, Objects, Methods and Strings" set of lecture notes. These two classes are reproduced below on page 2 and 3, respectively. 1) Recreate these two classes and compile them using the following command: > javac Account.java Account Test.java If your compilation is successful, you should now have account.class an AccountTest.class fles in your folder. Run this program using the following command: > java Account Test 2) Modify the Account class as follows: a) Replace balance with two instance variables: checkingbalance and savingsbalance and modify the constructor to take two arguments checking and savings. The constructor Initializes the two instance variables with the values given by the two arguments. Don't forget to modify the test driver accordingly. b) Replace the credit method with two methods: creditChecking and credit savings Also, Replace the getealance method with two methods: getcheckingsalance and getsavings Balance. Note: the credit operation adds amount to the account Add the following two new methods debitChecking and debitsavings and their corresponding tests. Note: the debit operation subtract amount from the account d) Add a method moveFromChecking Tosavings (double amount) Also Add a method moveFromsavings ToChecking (double amount) You must implement these two methods using credit checking, credit savings. debitChecking and/or debitsavings as appropriate Always ensure that the resulting balances do not become negative. If an account is debited with greater than the corresponding balance, then that balance should be left changed the thed debitChecking or debitsavings() should print Spring 2020 Spring 2020 CIS 254 IMPORTANT ADVICE Develop your program in successive phases: Do (a) only and modify the corresponding test (constructor now takes two arguments). Once (a) is working correctly, do (b) and modify the corresponding test Once(a) is working correctly, do (c) and add its corresponding test Finally, do (d) and its corresponding test Submit a ripped file that contains your modified Account.java and Account Test.java source code and a screenshot of the Virtual Window showing the test results. Submit thiszipped file into "Drop Box for Lab 6 Account.java Account class with a constructor to validate and initialize instance variable balance of type double. public class Account private double balance; // instance variable that stores the balance // constructor public Account double initialbalance ) // validate that initialBalance is greater than 0.0: // if it is not, balance is initialized to the default value 0.0 if (initialbalance > 0.0 ) balance initialaalance: ) // end Account constructor // credit Cadd) an amount to the account public void credit double amount ) balance - balance amount; // add amount to balance > // end method credit 1/ return the account balance public double getbalance() return balance // gives the value of balance to the calling method 3/ end ethod getbalance and class Account > Spring 2020 CIS 254 Spring 2020 CIS 254 Account Test.java Inputting and outputting floating-point numbers with account objects. import java.util.Scanner; public class Account Test 1/ main method begins execution of Java application public static void main(String[] args) Account account = new Account 50.00): // create Account object Account account 2 - new Account( -7.53 ); // create Account object 1/ display initial balance of each object System.out.printf("account balance: $%.2f ". account.getBalance()); System.out.printf("account balance: 5%.2f ". account.getBalance(): // create Scanner to obtain input from command window Scanner input = new Scanner(System.in); double depositAmount: // deposit amount read from user System.out.print("Enter deposit amount for accountl: "); // prompt depositAmount - input.nextDouble: // obtain user input System.out.printf(" adding %.2f to account balance ". depositAmount: accounti.credit( deposit Amount ); // add to account balance 1/ display balances System.out.printf("account balance $.2f " account.getBalance(): System.out.printf( account balancet 5%.2f ". account.getBalance(): System.out.print("Enter deposit mount for account 21 ): // prompt depositamount - input.nextDouble: // obtain user input System.out.printf("nadaing .2 to account balancel ". depositount ) account.credit depositat ): // add to account balance 1 display balances account2tbalance )

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!