Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

More Books

Students also viewed these Databases questions

Question

In java anytime we see the "new" operator, what is happening?

Answered: 1 week ago