Question: Write a Java application that determines whether any of several department store customers has exceeded the credit limit on a charge account. For each customer,

Write 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 inputted:

Account number: 9876 Balance at beginning of month: $1234 Total amount of all items charged by the customer this month:12 Total amount of all credits applied to the customers account this month: 9 Allowed credit limit: $2500

Use the value of -1 as a sentinel value to quit the program. The program should input all these facts, calculate the new balance (beginning balance + charges credits), display the new balance and determine whether the new balance exceeds the customers credit limit. For those customers whose credit limit is exceeded, the program should display the message Credit limit exceeded.

Use the sentinel control algorithm example below.

/* Addition Calculator - Sentinel Control Algorithm with an Accumulator

Sentinel Control Algorithm - When you dont know how many times the loop will go Use controls how many times the loop goes.

Sentinel guard, lookout (Dummy Value from input proved by user)

1. Priming read 2. Test input 3. Body - code to be repeated 4. Repeat read

While Loop

<1> while( <2> ) { <3> <4> }

*/

import java.util.Scanner;

public class Calculator2 { public static void main( String [] args ) { final int SENTINEL = 0; int number; int total = 0;

Scanner scan = new Scanner( System.in );

System.out.println( "Welcome to the addition calculator. " );

// 1. Priming Read System.out.print( "Enter the first number" + " or 0 for the total > " ); number = scan.nextInt( );

while ( number != SENTINEL ) // 2. Test LCV { // 3. Body - Accumulate Total total += number;

// 4.Repeat Read System.out.print( "Enter the next number" + " or 0 for the total > " ); number = scan.nextInt( ); } // Output Accumulator after the loop ends System.out.println( "The total is " + total ); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!