# Credit Limit Calculator In Java

Question: Develop a Java application that determines whether any of several department-store customers has exceeded the credit limit on a charge account. For each customer, the following facts are available:
1. account number
2. balance at the beginning of the month
3. total of all items charged by the customer this month
4. total of all credits applied to the customer’s account this month
5. allowed credit limit.
The program should input all these facts as integers, calculate the new balance (= beginning balance + charges – credits), display the new balance and determine whether the new balance exceeds the customer’s credit limit. For those customers whose credit limit is exceeded, the program should display the message "Credit limit exceeded".

```/**
*
* @Author: Aghatise Osazuwa
* Website: www.cscprogrammingtutorials.com
*
* Exercise 4.18 - Credit Limit Calculator
*
*/

import java.util.Scanner;

public class CreditLimitCalculator {

public static void main(String[] args) {

int accountNumber;  // stores the account number of the customer
int balance;  // stores the balance of the customer at the beginning of the month
int totalItems; // stores the total of all items charged by the customer this month
int totalCredits;  // stores the total of all credits applied to the customer’s account this month
int allowedCreditLimit;  // stores the allowed credit limit of the customer

Scanner input = new Scanner(System.in); //create scanner object for collecting input from user

System.out.println("This Application Determines Whether Any Of Several "
+ "Department-store \nCustomers Has Exceeded The Credit Limit On A Charge Account.\n");

System.out.println("Enter \"CUSTOMER ACCOUNT NUMBER\": ");
accountNumber = input.nextInt();

System.out.println();

System.out.println("Enter \"CUSTOMER BALANCE\" at the  beginning of the month: ");
balance = input.nextInt();

System.out.println();

System.out.println("Enter \"TOTAL OF ALL ITEMS CHARGED\" by the Customer this month: ");
totalItems = input.nextInt();

System.out.println();

System.out.println("Enter \"TOTAL OF ALL CREDITS APPLIED\" to the Customer this month: ");
totalCredits = input.nextInt();

System.out.println();

System.out.println("Enter the \"ALLOWED CREDIT LIMIT\" of the Customer: ");
allowedCreditLimit = input.nextInt();

System.out.println();

int newBalance = balance + totalItems - totalCredits;

System.out.println("Customer: " + accountNumber + "\n"
+ "Balance at the beginning of the month: " + balance + "\n"
+ "Total number of items charged this month: " + totalItems + "\n"
+ "Total number of Credits Applied this month: " + totalCredits + "\n");

System.out.println("The Customer's new Balance is " + newBalance);

System.out.println();

if (newBalance < allowedCreditLimit) {
System.out.println("CREDIT LIMIT EXCEEDED");
}

System.out.println();
}
}

```

 Program Output