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

C++ is the programming language Write a program that computes the total cost for

ID: 3925078 • Letter: C

Question

C++ is the programming language

Write a program that computes the total cost for the number of software licenses bought. Define two variables, numlicense and costPerLicense inside the main function and initialize them to zero. Now, define a new function ReadUserInput that initializes these two variables to user defined non-zero positive values. Finally, back in main function compute the total cost of the software purchase and print it on the console.

You MUST use references

Example:

****INSIDE Main, Calling ReadUserInput********

****INSIDE Read User Input****

How many licenses did you buy? 7

What is the cost of each license? 90

**** INSIDE MAIN ****

You bought 7 software licenses at $90 each, and the total cost is = $630

Explanation / Answer

using namespace std;
#include<iostream>
void ReadUserInput(int *numlicense, int *costPerLicense){
int flag=0;
do{
cout<<"How many licenses did you buy?";
cin>>(*numlicense);
cout<<"What is the cost of each license?";
cin>>(*costPerLicense);
if (*numlicense>0 && *costPerLicense>0)
flag=1;
if (flag==0)
cout<<"Please Enter Correct Values (A Non-Zero Value) ";
}while (flag==0);
}
int main(){
int numlicense=0,costPerLicense=0;
ReadUserInput(&numlicense, &costPerLicense);
cout<<"You bought "<<numlicense<<"software licenses at $"<<costPerLicense<<"each, and the total cost is = $"<<numlicense*costPerLicense;
return 0;
}

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