Question

You are to write a program IN C++ that asks the user to enter an item's...

You are to write a program IN C++ that asks the user to enter an item's wholesale cost and its markup percentage.
It should then display the item's retail price. For example:

if the an item's wholesale cost is 5.00 and its markup percentage is 100%, then the item's retail price is 10.00
If an item's wholesale cost is 5.00 and its markup percentage is 50%, then the item's retail price is 7.50

Program design specs.

You should have 5 functions. main, 2 user input functions, a function that calculates the markup price and a function that displays the retail price.

Note: Code order: Put all #include statements, then using namespace std;, then your function prototypes, then main, then your user-defined functions.

DESIGN NOTE:   You will pass data by value (i.e. only a copy of the variable)   for ALL of your user-defined functions!


The main function should call the 1st user input function. This user input function will ask the user to input the wholesale cost of an item. Note: Use minor error checking for this function. Don't allow user to enter in a negative wholesale cost or a wholesale cost of 0.    This function should return the wholesale cost back to main. The prototype for this function should be:

double functionname( );

The main function should then call the 2nd user input function. This user input function will ask the user to input the desired markup percentage of an item. Minor error checking for this function. Don't allow user to enter in a negative markup percentage or a markup percentage of 0.    This function should return the markup percentage back to main. The prototype for this function should be:

double functionname( );

The main function should then call the markup price calculation function and pass wholesale cost and markup percentage down to it. NOTE: Pass by value, not by reference! The markup calculation function should compute the retail price and return it to main. The prototype for the markup price function should be:   double functionname(double,double);


main should should then call the display function and pass it the retail price. The display function
will display the price   (format the price to two decimal places )   . This function will NOT return anything.

function prototype for display function should be:   void functionname(double);

NOTE: A loop should be created within main so that the user could calculate for different wholesale costs & markups.

As usual, your program should include your program heading with your name along with program documentation. You NEED to follow design specs to get full points for the program.

To summarize here are all the function prototypes that you need:

double functionname( ); // this function will ask user for wholesales cost & return this to main

double functionname( ); // this function will ask user for markup percentage & return this to main

double functionname(double,double);//this function will get wholesale cost & markup percentage & compute retail price & return retail price to main

void functionname(double);//this function will display the retail price - use 2 digits to right of decimal

0 0
Add a comment Improve this question Transcribed image text
Answer #1

code:

#include <iostream>
using namespace std;
double input() //fuction to get wholesale cost
{
double n;
cout<<"Enter the item's wholesale cost:";
cin >>n;
if (n<=0)//condition to check the positive value
{
while(1)
{
cout<<"Enter a positive value for the wholesale cost:";
cin>>n;
if(n>0)
{
return n;
}
}
}
return n;//return the cost
}
double markup()//function for markup percentage
{
double n;
cout<<"Enter item's markup percentage:";
cin >>n;
if (n>0)
{
return n;
}
else
{
markup();
//itrate the process untill positive input is given
}
}
double Markup_cal(double a,double b)
//function to calculate the total price
{
double total;
total=a+(a*b/100);
//total=wholesale price+markup price
return total;
}
void display(double retail)
{
printf("The item's retail price is $%.2f\n",retail);
//display with 2 decimal points
}
int main()
{
char choice;
while(1)
//repete process untill user terminates
{
double rate=input();
double markupper=markup();
double total=Markup_cal(rate,markupper);
display(total);
//Calling all the functions
cout<<"Do you wish to calculate another?Y/N";
cin>>choice;
if(choice=='y' || choice=='Y')
{
continue;
}
else if(choice=='n' || choice=='N')
{
return 0;
}
else
{
cout<<"enter correct choice\n";
}
}
}

#include <iostream> using namespace std double input() //fuction to get wholesale cost { double n; cout<<Enter the items wh

void display(double retail) printf(The items retail price is $%.2f\n, retail); //display with 2 decimal points } int main(


output:

Enter the items wholesale cost:50.00 Enter items markup percentage:10 The items retail price is $55.00 Do you wish to calc

//if any doubt, please comment

Add a comment
Know the answer?
Add Answer to:
You are to write a program IN C++ that asks the user to enter an item's...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. Markup Write a program that asks the user to enter an item's wholesale cost and...

    1. Markup Write a program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: . If an item's wholesale cost is $5.00 and its markup percentage is 100 percent, then . If an item's wholesale cost is $5.00 and its markup percentage is 50 percent, then The program should have a function named calculateReta1l that receives the wholesale the item's retail price is $10.00. the...

  • Price Markup Write a program that asks the user to enter an item’s wholesale cost and...

    Price Markup Write a program that asks the user to enter an item’s wholesale cost and its markup percentage. It should then display the item’s retail price. For example: If an item’s wholesale cost is 5.00 and its markup percentage is 100%, then the item’s retail price is 10.00. If an item’s wholesale cost is 5.00 and its markup percentage is 50%, then the item’s retail price is 7.50. The program should have a function named calculateRetail that receives the...

  • Write a console-based program ( C # ) that asks a user to enter a number...

    Write a console-based program ( C # ) that asks a user to enter a number between 1 and 10. Check if the number is between the range and if not ask the user to enter again or quit. Store the values entered in an array. Write two methods. Method1 called displayByVal should have a parameter defined where you pass the value of an array element into the method and display it. Method2 called displayByRef should have a parameter defined...

  • Write a program that will ask the user to enter 4 quiz scores. These scores should...

    Write a program that will ask the user to enter 4 quiz scores. These scores should be from 0 to 100. Use a procedure and pass by reference to get these scores. Write a function that will find the lowest score. This score will be sent back through the function call. You still need to pass the scores by value to this function. Write a function that will calculate the average score. This value will be sent back to main...

  • Write a C++ program that asks user number of students in a class and their names....

    Write a C++ program that asks user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’ names and ranking. Follow the Steps Below Save the project as A4_StudentRanking_yourname....

  • Write program in C. Please ask the user to determine how many numbers to enter, and...

    Write program in C. Please ask the user to determine how many numbers to enter, and then find and display the largest one with two digits. Please call the following two functions in your main functions. void input_numbers(float *data, int num); void find_largest(float *data, int num); Note: In this assignment, please save the entered numbers using pointer, pass the pointer as the arguments. Depending upon the number of elements, the required size is allocated which prevents the wastage of memory....

  • A) One of the problems that have been discussed in the class is to write a simple C++ program to ...

    C++ programming question will upvote A) One of the problems that have been discussed in the class is to write a simple C++ program to determine the area and circumference of a circle of a given radius. In this lab you will be rewriting the program again but this time you will be writing some functions to take care of the user input and math. Specifically, your main function should look like the following int main //the radius of the...

  • IN C language Write a C program that prompts the user to enter a line of...

    IN C language Write a C program that prompts the user to enter a line of text on the keyboard then echoes the entire line. The program should continue echoing each line until the user responds to the prompt by not entering any text and hitting the return key. Your program should have two functions, writeStr andcreadLn, in addition to the main function. The text string itself should be stored in a char array in main. Both functions should operate...

  • In this program, you will be using C++ programming constructs, such as functions. main.cpp Write a...

    In this program, you will be using C++ programming constructs, such as functions. main.cpp Write a program that asks the user to enter an integer value. Your program will then display that integer back to the user. Your program should include a function called getInteger that requests an integer value from the user and returns that value back to the caller. Your main () function will call the function getInteger and will then display the value returned by that function....

  • CE – Return and Overload in C++ You are going to create a rudimentary calculator. The...

    CE – Return and Overload in C++ You are going to create a rudimentary calculator. The program should call a function to display a menu of three options: 1 – Integer Math 2 – Double Math 3 – Exit Program The program must test that the user enters in a valid menu option. If they do not, the program must display an error message and allow the user to reenter the selection. Once valid, the function must return the option...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT