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

Write a program that calculates the current checking account balance, based on u

ID: 3754399 • Letter: W

Question

Write a program that calculates the current checking account balance, based on user inpu Inputs: Ask user for account number and name. Ask user for opening balance. Ask user for up to 5 debit transactions, user can stop entering by typing-1. Ask user for up to 5 credit transactions, user can stop entering by typing -1. Processing: Calculate new balance. Output Account number]- [Customer first name] [Customer last name] Original Balance: [Original balance Debits: [Number of debits) Debit Total: [Debit total] Credits: [Number of credits] Credit Total: (Credit total] Balance: [Current account balancel Sample output: 123456789- Robert Robertson Original Balance: $100.00 Debits: 5 Debit Total: $10.00 Credits: 5 Credit Total: $20.00 Balance: $110.00

Explanation / Answer

Solution:-
import java.util.Scanner;
class Main {
public static void main(String[] args) {
// scanner to read intpu
Scanner sc = new Scanner(System.in);
//declare varaibles
int accountNumber;
String fname;
String lname;
float balance;
float withdrawlTotal=0;
int withdraws=0;
float depositTotal=0;
int deposits=0;
  
// get input from user
System.out.print("Enter AccountNumber:");
accountNumber = sc.nextInt();
System.out.print("Enter Customer First Name");
fname = sc.next();
System.out.print("Enter Customer Last Name:");
lname = sc.next();
  
System.out.print("Enter Original balance:");
balance = sc.nextFloat();
  
// get 5 withdrawls from user
for(int i=0;i<5;i++){
System.out.print("Enter withdrawl amount, -1 to exit:");
float temp = sc.nextFloat();
if(temp==-1){
break;
}
withdraws++;
withdrawlTotal += temp;
}
  
// get 5 deposits from user
for(int i=0;i<5;i++){
System.out.print("Enter deposit amount, -1 to exit:");
float temp = sc.nextFloat();
if(temp==-1){
break;
}
deposits++;
depositTotal += temp;
}
  
// print output to screen.
System.out.printf("%d - %s %s ",accountNumber,fname,lname);
System.out.printf("Original Balance: $%.2f ",balance);
System.out.println("Withdrawls:"+withdraws);
System.out.printf("withdrawl Total:$%.2f ",withdrawlTotal);
System.out.println("Deposits:"+deposits);
System.out.printf("Deposit Total:$%.2f ",depositTotal);
System.out.printf("Balance:$%.2f ",(balance-withdrawlTotal+depositTotal));
}
}

/*
sample output
Enter AccountNumber: 123456789
Enter Customer First Name Robert
Enter Customer Last Name: Robertson
Enter Original balance: 100
Enter withdrawl amount, -1 to exit: 10
Enter withdrawl amount, -1 to exit: 10
Enter withdrawl amount, -1 to exit: 10
Enter withdrawl amount, -1 to exit: 10
Enter withdrawl amount, -1 to exit: 10
Enter deposit amount, -1 to exit: 20
Enter deposit amount, -1 to exit: 20
Enter deposit amount, -1 to exit: 30
Enter deposit amount, -1 to exit: 40
Enter deposit amount, -1 to exit: 50
123456789 - Robert Robertson
Original Balance: $100.00
Withdrawls:5
withdrawl Total:$50.00
Deposits:5
Deposit Total:$160.00
Balance:$210.00

--------------------------------------------------THANK YOU--------------------------------------------

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