Search Blog

Biyernes, Enero 18, 2013

Develop a program that will determine if a department store customer 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 this customer this month 4. Total of all credits applied to this customer’s account this month 5. Allowed credit limit The program should input each of these facts, calculate the new balance (= beginning balance + charges – credits), and determine if the new balance exceeds the customer’s credit limit. For those customers whose credit limit is exceeded, the program should display the customer’s account number, credit limit, new balance, and the message “Credit limit exceeded.”


Java Codes
--+o0O0o+--


Develop a program that will determine if a department store customer 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 this customer this month
4.Total of all credits applied to this customer’s account this month
5.Allowed credit limit

The program should input each of these facts, calculate the new balance (= beginning balance + charges – credits), and determine if the new balance exceeds the customer’s credit limit. For those customers whose credit limit is exceeded, the program should display the customer’s account number, credit limit, new balance, and the message “Credit limit exceeded.”


Code:

import java.util.Scanner;

public class MachineProblem8 {

    public static void main(String[] args) {
       
         Scanner input_user = new Scanner(System.in);
       
        int  account_number;
        float beginning_balance,total_charges;
        float total_credits,credit_limit,new_bal;
       
        System.out.println("*****************************************");
        for(int x = 0;x < 1000;x++)
        { 
           
         System.out.print(" Enter account number (-1 to end): ");
            account_number = input_user.nextInt();
           
            if(account_number != -1)
            {
                System.out.print(" Enter beginning balance: ");
                beginning_balance = input_user.nextFloat();
               
                System.out.print(" Enter total charges: ");
                total_charges = input_user.nextFloat();
               
                System.out.print(" Enter total credits: ");
                total_credits = input_user.nextFloat();
               
                System.out.print(" Enter credit limit: ");
                credit_limit = input_user.nextFloat();


new_bal = beginning_balance + total_charges - total_credits;
                    if(new_bal > credit_limit)
                    {
                        System.out.println("*****************************************");

       System.out.println("     Account: " + account_number);
       System.out.println("     Credit Limit: " + credit_limit);
       System.out.println("     Balance: " + beginning_balance);
                        System.out.println("******************************************");
                        System.out.println("=========================================");
       System.out.println("||     CREDIT LIMIT EXCEEDED    ||");
System.out.println("=========================================");
                    }
               
System.out.println("*****************************************");
            }
            else
            {
                return;
            }  
               
            
        }
    }
}

1 komento: