Question: Main topics: Programmer Defined Methods Exercise This lab is designed to give you practice working with programmer defined methods. You will write a method named

Main topics: Programmer Defined Methods

Exercise

This lab is designed to give you practice working with programmer defined methods. You will write a method named transaction to help a local banker. Your method will need to utilize two input parameters and the methods return value (for its output).

Getting Started To start this exercise, you should

1. Open eclipse and start a new Java project named Lab09

2. Add a Class (named Lab09) to this project.

3. Cut the program from this document and paste (replacing everything) in the Eclipse editor window.

Lab09.Java

 /* Comment block here ... */ import java.util.Scanner; 
 public class Lab09 { 
 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 = transaction(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! "); 
 stdIn.close(); } 
 public static double transaction(double bal, double amount) { 
 // Write your code here ... 
 return 0.0; // actual return value here (NOT 0.0) } 

}

Problem Description

Read through the existing code to understand what it does and what is left for you to do.

Compile and run the program as-is, to verify that you understand what it does and what is left

for you to do.

Write the missing code in the Java program program provided so that it satisfies the following specification:

For this part of the assignment you will be using the Lab08.java file that you copied using the command above.

A local banker has asked you to write a method named transaction which takes : a customers 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.

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!