Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The following are from the Algorithm Workbench in your book on page 140. You are

ID: 3754875 • Letter: T

Question

The following are from the Algorithm Workbench in your book on page 140. You are to complete one of these three for your practice program 25. A retail store grants its customers a maximum amount of credit. Each customer's available credit is his or her maximum amount of credit minus 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 After you write the pseudocode algorithm, convert it to a complete C++ program.

Explanation / Answer

Algorithm

Function calculateAvailableCredit()

BEGIN

    max_credit = ask user to enter maximum credit

   

credit_used = ask user to enter amount of credit used

    // calculate the amount of credit available

    credit_available = max_credit – credit_used

    print(“Credit Available : $” + credit_available)

END

Code

#include<iostream>

using namespace std;

int main()

{

    double max_credit, credit_used;

   

    cout<<"Enter the maximum credit : $";

   

    // get user input

    cin>>max_credit;

   

    cout<<"Enter the amount of credit used : $";

   

    // get user input

    cin>>credit_used;

   

    // calculate the amount of credit available

    double credit_available = max_credit - credit_used;

   

    cout<<"Credit Available : $"<<credit_available;

      

    return 0;

}

Sample Output

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote