** write a method named validate to help a local banker. Your method will need t
ID: 3641719 • Letter: #
Question
** write a method named validate to help a local banker. Your method will need to utilize two input parameters and the method's return value (for its output).**Write the missing code in the Java program program provided so that it satisfies the following specification:
***A local banker has asked you to write a method named validate which takes :
*a customer's current balance
*the amount of money to update the account by :
*a positive dollar amount is a deposit
*a negative dollar amount is a withdraw
------- as input parameters, and then returns
**for deposits: the deposit amount is simpily returned by the function.
**for withdraws: the balance must not become negative. If a withdraw is requested for more than the current balance then the amount (which would zero the balance if withdrawn) is returned by the method. Otherwise the withdraw amount is simpily returned by the method.
import java.util.Scanner;
public class Lab11
{
public static void main(String[] args)
{
Scanner stdIn = new Scanner(System.in);
double curBal = 45.32;
double amount;
System.out.print("Please enter a amount to update account by $");
amount = stdIn.nextDouble();
System.out.print(" ");
System.out.print("Customer's balance (before transaction) = $");
System.out.println(curBal + " ");
System.out.print("Requested update amount = $");
System.out.println(amount + " ");
double actAmount;
actAmount = validate(curBal, amount);
curBal += actAmount;
System.out.print("Actual update amount = $");
System.out.println(actAmount + " ");
System.out.print("Customer's balance (after transaction) = $");
System.out.println(curBal + " ");
System.out.println(" Thank you and good-bye! ");
}
public static double validate(double bal, double amount)
{
// Write your code here ...
return 0.0; // actual return value here (NOT 0.0)
}
}
Explanation / Answer
public static double validate(double bal, double amount) { if(amount>0) { //customer deposits money return amount; } if((bal+amount)Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.