Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Import the Scanner class
- import java.util.Scanner;
- public class Task_2 {
- public static void main(String[] args) {
- // Create a Scanner object
- Scanner myNum = new Scanner(System.in);
- // Prompt user to enter customer's account number
- System.out.print("Enter the customer's account number: ");
- int accountNumber = myNum.nextInt();
- // Prompt user to enter the starting balance
- System.out.print("Enter the balance at the beginning of the month: ");
- int startingBalance = myNum.nextInt();
- // Prompt user to enter the total items charged
- System.out.print("Enter the total items charged by the customer this month: ");
- int totalItems = myNum.nextInt();
- // Prompt user to enter the total credits applied
- System.out.print("Enter the total credits applied to the customer’s account this month: ");
- int totalCredits = myNum.nextInt();
- // Prompt user to enter customer's credit limit
- System.out.print("Enter the customer's allowed credit limit: ");
- int creditLimit = myNum.nextInt();
- // Calculate the new balance
- int newBalance = (startingBalance + totalItems - totalCredits);
- System.out.println("The customer's new balance is " + newBalance + ".");
- // Insert a new line
- System.out.println("");
- // Display result
- if (newBalance < creditLimit) {
- System.out.println("The new balance is within the customer's credit limit.");
- } else {
- System.out.println("Account Number: " + accountNumber);
- System.out.println("Credit Limit: " + creditLimit);
- System.out.println("New Balance: " + newBalance);
- System.out.println("Credit Limit Exceeded");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement