A retail score grants its customers a maximum amount of 1:rcdit. Each customer's available credit is his or her maximum amount of credit miniJS the amount of credit used. Write a pseudocode algorithm for a program that asks for a customer's maximum amount of credit and amount of credit used. The program should then display the customer's available credit.

Respuesta :

Answer:

Pseudocode algorithm:

Start

Declare variables maxCredit, usedCredit and availableCredit

PRINT "Enter the customer's maximum amount of credit"

READ maxCredit

PRINT "Enter the amount of credit the customer has used "

READ usedCredit

COMPUTE availableCredit = maxCredit - usedCredit

PRINT availableCredit

End

The above psedudcode can also be written as

Declare variables maxCredit and usedCredit

Display"Enter the customer's maximum amount of credit"

READ maxCredit

Display"Enter the amount of credit the customer has used "

READ usedCredit

COMPUTE availableCredit = maxCredit - usedCredit

Display availableCredit

Explanation:

The above pseudocode algorithm first declares two variables maxCredit and usedCredit.

Then in order to take customer's maximum amount from user it displays a message "Enter the customer's maximum amount of credit". Then it reads the value of maxCredit entered by the user.

Then in order to take value of amount of credit used from user, it displays a message "Enter the amount of credit the customer has used ". Then it reads the value of usedCredit entered by the user.

This is the requirement of the question. I have written the further part of algorithm to compute the available credit. The available credit is computed by subtracting maximum amount of credit and the amount of credit used i.e. availableCredit = maxCredit - usedCredit.

At the end the result of this subtraction is stored in availableCredit and value of availableCredit is displayed using PRINT availableCredit.

The corresponding C++ program of the above pseudocode algorithm is as following:

#include <iostream>  //to use input output functions

using namespace std;   // to identify objects like cin cout

int main()  {  // start of main() function body

double maxCredit, usedCredit, availableCredit;   // declare variables

//prompts user to enter the value of  maximum credit

cout << "Enter the customer's maximum amount of credit: ";

cin >> maxCredit;  //reads the value of maximum credit from user

//prompts user to enter used credit

cout << "Enter the amount of credit used by the customer: ";

cin >> usedCredit;  //reads the used credit value from user

availableCredit = maxCredit - usedCredit;  //computes available credit

cout << "The customer's available credit is: ";  //displays this message

cout << availableCredit; } //displays the value of computed available credit

//The output is attached in screenshot

Ver imagen mahamnasir