The code has been test to work by the parameters listed below I just wanted to know if there were any details that I missed or blatantly overlooked.
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:
account number
balance at the beginning of the month
total of all items charged by the customer this month
total of all credits applied to the customers account this month
allowed credit limit
The program should input all of these facts as integers, calculate the new balance (new balance = beginning balance + charges - credits) For those customers whose credit limit is exceeded, the program should display the message "Credit Limit Exceeded".
import java.util.Scanner;
public class CreditCalc
{
public static void main(String[] args)
{
Scanner input = new Scanner( System.in );
int accnum = 0;
int begBalance = 0;
int itemTotal = 0;
int creditsApplied = 0;
int creditLimit = 0;
int newBalance = 0;
System.out.println("Welcome to the Credit Calculator");
System.out.println("Please Enter Customer Account Number (or -1 to quit): ");
accnum = input.nextInt();
if (accnum != -1)
{
System.out.println("Please Enter Customer Beginning Balance: ");
begBalance = input.nextInt();
if (begBalance < 0)
{
System.out.println("Please enter a positive amount");
System.out.println("Please Enter Customer Beginning Balance: ");
begBalance = input.nextInt();
}
}
while(accnum != -1)
{
System.out.println("Please Enter Total of Items Purchased this Month: ");
itemTotal = input.nextInt();
if (itemTotal < 0)
{
System.out.println("Please enter a positive amount");
System.out.println("Please Enter Total of Items Purchased this Month: ");
itemTotal = input.nextInt();
}
System.out.println("Please Enter Credits applied to Customer Account: ");
creditsApplied = input.nextInt();
System.out.println("Please Enter Customer Credit Limit: ");
creditLimit = input.nextInt();
newBalance = begBalance + itemTotal - creditsApplied;
if(newBalance > creditLimit)
{
System.out.println("Credit Limit Exceeded");
}
System.out.println("Please Enter Customer Account Number (or -1 to quit): ");
accnum = input.nextInt();
if (accnum != -1)
{
System.out.println("Please Enter Customer Beginning Balance: ");
begBalance = input.nextInt();
if (begBalance < 0)
{
System.out.println("Please enter a positive amount");
System.out.println("Please Enter Customer Beginning Balance: ");
begBalance = input.nextInt();
}
}
}
if(accnum < 0)
{
System.out.println("Thank You for using Credit Calculator");
System.out.println("Goodbye");
}
}
}