data from the user. 4.18 (Credit Limit Calculator) Develop a Java application th
ID: 3602917 • Letter: D
Question
data from the user. 4.18 (Credit Limit Calculator) 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: a) account number b) balance at the beginning of the month c) total of all items charged by the customer this month d) total of all credits applied to the customer's account this month e) allowed credit limit. The program should input all these facts as integers, calculate the new balance (+ beginning balance + charges- redits), 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 dis- play the message "Credit limit exceeded".Explanation / Answer
import java.util.Scanner;
public class CreditLimit {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int accountNumber;
int balanceAtBegining;
int totalOfAllItems;
int totalOfAllCredits;
int allowedCrediteds;
int newBalance;
System.out.println("Enter account number");
accountNumber=sc.nextInt();
System.out.println("Enter balance in the begining of the month");
balanceAtBegining=sc.nextInt();
System.out.println("Enter total of all items charged by the customer this month");
totalOfAllItems=sc.nextInt();
System.out.println("Enter total of all credits applied to the customer this month");
totalOfAllCredits=sc.nextInt();
newBalance=balanceAtBegining+totalOfAllItems-totalOfAllCredits;
System.out.println("new Balance is "+newBalance);
if(newBalance<totalOfAllCredits)
System.out.println("Credit limit exceeded");
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.