Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 V/ This class will be tested 2. public class MathMachine { 3 4 // One variable as operands for the math operations 5 //

image text in transcribed

1 V/ This class will be tested 2. public class MathMachine { 3 4 // One variable as operands for the math operations 5 // values assigned in main by VPL testing system. 6 private int cardBalance; 7 8 // Bring in the variable values from outside MathMachine to be used 9 // inside MathMachine. VPL'S JUnit will do this. No changes here. 10 public MathMachine (int user Inputone) 11 - { 12 this.cardBalance = user Inputone; 13 } 14 15 // Dear student: make changes below here. 16 17 // vvvvvvvvvvvvvvv vvvvvvvvvvvvvvvvvvv VVVVVVVVVVV 18 19 // Operation: Transaction Request 20 // This is used to check whether the transaction can be made 21 // Compare the charge value against the card balance and accept or decline 22 // Modify between { and }. If valid (accepted), return true. If not valid 23 11 (declined) return false. Print information to inform the user. 24 public boolean transactionRequest(int chargeValue) 25 { 26 if () // Dear student: Modify this line 27 { 28 System.out.println("The requested amount exceeds the amount in the account"); 29 return false; 30 } 31 else 32 { 33 System.out.println("The requested amount is okay."); 34 return true; 35 } 36 } 37 38 // AAAAAAAAAAAAAAAAAAAAAA . AAAAAAAAAAAAAAAAAAAAAAAAAAA In this activity, you will modify a method (function) to simulate a financial transaction check. Just like when you use your debit card at an ATM. The requested transaction either gets accepted or declined by the bank. By modifying an if- else statement you will be able to perform this check. If the transaction requested cannot be processed due to insufficient funds, tell the user. If the transaction can succeed, then tell the user that that is the case. Your task: Add to the MathMachine.java file so that it has a complete code block called the transaction Request() method. Fill in the Boolean logic in the if statement so that

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

How does the EEOC interpret the national origin guidelines?

Answered: 1 week ago