SHARE
TWEET

Untitled

Ocha_DSH May 27th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Import the Scanner class
  2. import java.util.Scanner;
  3.  
  4. public class Task_2 {
  5.  
  6.     public static void main(String[] args) {
  7.        
  8.         // Create a Scanner object
  9.         Scanner myNum = new Scanner(System.in);
  10.        
  11.         // Prompt user to enter customer's account number
  12.         System.out.print("Enter the customer's account number: ");
  13.         int accountNumber = myNum.nextInt();
  14.        
  15.         // Prompt user to enter the starting balance
  16.         System.out.print("Enter the balance at the beginning of the month: ");
  17.         int startingBalance = myNum.nextInt();
  18.  
  19.         // Prompt user to enter the total items charged
  20.         System.out.print("Enter the total items charged by the customer this month: ");
  21.         int totalItems = myNum.nextInt();
  22.  
  23.         // Prompt user to enter the total credits applied
  24.         System.out.print("Enter the total credits applied to the customer’s account this month: ");
  25.         int totalCredits = myNum.nextInt();
  26.  
  27.         // Prompt user to enter customer's credit limit
  28.         System.out.print("Enter the customer's allowed credit limit: ");
  29.         int creditLimit = myNum.nextInt();
  30.  
  31.         // Calculate the new balance
  32.         int newBalance = (startingBalance + totalItems - totalCredits);
  33.         System.out.println("The customer's new balance is " + newBalance + ".");
  34.  
  35.         // Insert a new line
  36.         System.out.println("");
  37.  
  38.         // Display result
  39.         if (newBalance < creditLimit) {
  40.             System.out.println("The new balance is within the customer's credit limit.");
  41.         } else {
  42.             System.out.println("Account Number: " + accountNumber);
  43.             System.out.println("Credit Limit: " + creditLimit);
  44.             System.out.println("New Balance: " + newBalance);
  45.             System.out.println("Credit Limit Exceeded");
  46.         }
  47.  
  48.     }
  49. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top