Question
Ex: If the input is: 100 200 50 n the output is: Enter a starting balance Enter credits Enter debits Your new balance is: 250.00
Ex: If the input is:
100 200 50 n
the output is:
Enter a starting balance Enter credits Enter debits Your new balance is: 250.00 Continue?: y / n
REQUIREMENTS
- Prompt user for an opening balance, credits, and debits.
- Output the new balance
- The user should be prompted to enter new credits and debits until they indicate the are ready to exit the program
Note:
Output each floating-point value with two digits after the decimal point, which can be achieved as follows: System.out.printf("%.2f", yourValue);
Hints:
You have to store dollars and cents, so think about what variable types you'll be using for beginning balance, debits and credits A while loop will prompt the user to enter debits and credits until the user enters a "n". You'll need to prompt the user for a single character (y or n). This is how you do it: userChar = scnr.next().charAt(0);
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
/* Type your code here. */
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started