-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreditLimitCalculator.java
More file actions
38 lines (27 loc) · 1.19 KB
/
CreditLimitCalculator.java
File metadata and controls
38 lines (27 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import java.util.Scanner;
public class CreditLimitCalculator {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int accountNumber;
double beginningBalance, charges, credits, creditLimit;
System.out.print("Enter account number (-1 to quit): ");
accountNumber = sc.nextInt();
while (accountNumber != -1) {
System.out.print("Enter beginning balance: ");
beginningBalance = sc.nextDouble();
System.out.print("Enter total charges this month: ");
charges = sc.nextDouble();
System.out.print("Enter total credits this month: ");
credits = sc.nextDouble();
System.out.print("Enter credit limit: ");
creditLimit = sc.nextDouble();
double newBalance = beginningBalance + charges - credits;
System.out.println("New balance: " + newBalance);
if (newBalance > creditLimit) {
System.out.println("Credit limit exceeded.");
}
System.out.print("\nEnter account number : ");
accountNumber = sc.nextInt();
}
}
}