Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Exercise This lab is designed to give you practice working with programmer defin

ID: 3705989 • Letter: E

Question

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 method’s 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

}

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 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.

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 method's 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 ab09. Jav Comment block here import java.util.Scanner; public class Lab08 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("n"); 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);

Explanation / Answer

import java.util.Scanner;

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 = 0.0;

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.print(" Thank you and good-bye! ");

stdIn.close();


}

public static double transaction(double balance,double amount)
{
   double updateAmount = 0.0;

// if amount is negative and less than balance or amount is positive, do the transaction
  if(amount<0 && balance > amount || amount > 0)
  updateAmount = amount;
  
  return updateAmount;
}
}

Output:

Please enter a amount to update account by $-70
Customer's Balance (before transaction)=$ 45.32

Requested update amount = $-70.0

Actual update amount = $0.0

Customer's Balance (after transaction)=$ 45.32


Thank you and good-bye!

Do ask if any doubt. Please upvote.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote