Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java!!!!! Plz help!!! Q1: Q2: Q3: ' Tester BankAccount.java public class Tester i public static void main(String[] args) { BankAccount myBankAccount = new BankAccount(): myBankAccount.

Java!!!!! Plz help!!!

image text in transcribed

image text in transcribedimage text in transcribed

Q1:

image text in transcribed

image text in transcribed

Q2: image text in transcribedQ3:

image text in transcribed'

image text in transcribed

Tester BankAccount.java public class Tester i public static void main(String[] args) { BankAccount myBankAccount = new BankAccount(): myBankAccount. deposit(500): myBankAccount. withdraw (260): double result = myBankAccount.getBalance(): } } What is the final value of result? Submit Tester Point.java public class Tester i public static void main(String[] args) { Point p = new Point(); D. set1 (7): int result = p.getX() + p.getY(): } } What is the final value of result? Submit Tester Cash Register.java public class Tester i public static void main(String[] args) { CashRegister register = new CashRegister(): register. recordPurchase (0.75): register.recordPurchase (2.50): register.enterPayment (5, 0,5, 0, 0); double result - register. giveChange(): } } What is the final value of result? Submit Tester BankAccount.java A bank account has a balance that can be changed by deposits and withdrawals. public class BankAccount { /** Constructs a bank account with a zero balance. public BankAccount() { balance = 0; } Constructs a bank account with a given balance. @param initialBalance the initial balance public BankAccount (double initialBalance) { balance - initialBalance: } /** Deposits money into the bank account. @param amount the amount to deposit public void deposit (double amount) { double newBalance = balance + amount: balance = newBalance: } /** Withdraws money from the bank account. @param amount the amount to withdraw /** Withdraws money from the bank account. @param amount the amount to withdraw public void withdraw(double amount) { double newBalance = balance amount balance = newBalance: } /** Gets the current balance of the bank account. @return the current balance public double getBalance() { Tester Point.java public class Point 1 private int x = 0: private int y = 0; public Point () { x = 0 y = 0; } //constructor public Point (int a, int b) { X = a: y = b; } public void setX(int a) { } public int getX() { return x; } public int getY() { return y } } Tester Cash Register.java A cash register totals up sales and computes change due. public class CashRegister { Constructs a cash register with no money in it. public CashRegister() { purchase 0: payment = 0; } /** Records the sale of an item. @param amount the price of the item public void recordPurchase (double amount) { double total = purchase + amount; purchase = total: } Enters the payment received fro customer. @param amount the amount of the payment public void enterPayment (double amount) { payment = amount: } Enters the payment received from the customer. @param dollars the number of dollars in the payment @param quarters the number of quarters in the payment @param dimes the number of dimes in the payment @param nickels the number of nickels in the payment @param pennies the number of pennies in the payment public void enterPayment (int dollars, int quarters, int dimes, int nickels, int pennies) { payment = dollars + quarters * QUARTER_VALUE + dimes * DIME_VALUE + nickels * NICKEL_VALUE + pennies * PENNY_VALUE : Computes the change due and resets the machine for the next customer. @return the change due to the customer public double giveChange() purchase: = double change = payment purchase 0; Payment = 0; return change: } public static final double QUARTER_VALUE = 0.25 : public static final double DIME_VALUE = 0.1; public static final double NICKEL_VALUE = 0.05; public static final double PENNY_VALUE = 0.01; private double purchase: private double payment: }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

5. Develop the succession planning review.

Answered: 1 week ago