Need Assistance fixing this program

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 wholesale
cost and the markup percentage as arguments, and returns the retail price of the item.

SAMPLE RUN OUTPUT

Enter the item's wholesale cost: 8.00

Enter the item's markup percentage (e.g. 15.0): 30

The retail price is $10.40
----------------------------
When I run the program from the sample run output I get $248 instead of $10.40 and I'm confused as to what I'm doing wrong. Any help is appreciated.

Here is what I have so far:

#include
#include
using namespace std;

// function prototype
double calculateRetail();

int main()
{
double RetalPrice;
cout << "This program calculates and displays the retail price of an item.\n";
RetalPrice = calculateRetail();
cout << fixed << showpoint << setprecision(2);
cout << "The retail price of the item is $" << RetalPrice <<endl;
return 0;
}

double calculateRetail()
{
double Cost,
Markup;

do
{
cout << "What is the item's wholesale cost? ";
cin >> Cost;
if (Cost < 0)
{
cout << "Error!\n"
<< "Wholesale cost must be a positive number.\n";
}
} while (!(Cost > 0));
do
{
cout << "What is the item's markup percentage? ";
cin >> Markup;
if (Markup < 0)
{
cout << "Error!\n"
<< "The markup percentage must be a positive number.\n";
}
} while (!(Markup > 0));

Markup /= 100;
return Cost * (1 + Markup);
}

248 is 8 * 31. Did you forget to rebuild the executable after adding the division by 100?
When posting, please use code tags so that the code is readable!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
#include <iomanip>
using namespace std;

// function prototype
double calculateRetail();

int main()
{
	cout << "This program calculates and displays the retail price of an item.\n";

	const auto RetalPrice {calculateRetail()};

	cout << fixed << showpoint << setprecision(2);
	cout << "The retail price of the item is $" << RetalPrice << '\n';
}

double calculateRetail()
{
	double Cost {}, Markup {};

	do {
		cout << "What is the item's wholesale cost? ";
		cin >> Cost;

	} while ((Cost <= 0) && (cout << "Error! Wholesale cost must be a positive number.\n"));

	do {
		cout << "What is the item's markup percentage? ";
		cin >> Markup;

	} while ((Markup <= 0) && (cout << "Error! The markup percentage must be a positive number.\n"));

	return Cost * (1.0 + (Markup / 100.0));
}

Topic archived. No new replies allowed.