Chpt 6, pg 323 - 342 1. Write a program. After reading the specifications below,
ID: 647259 • Letter: C
Question
Chpt 6, pg 323 - 342
1. Write a program. After reading the specifications below, write the pseudo code in the comments before writing the code. The program should ask the user to enter an item's wholesale cost and it markup percentage. (cost of product * markup percent = markup) (retail = cost of product + markup) The program should validate the inputs. (Note: markup should be greater than zero but less than one) The program should display the item's retail price with two decimal places. The program should have a void function named calculateRetail that receives the wholesale cost and the markup percentage as arguments, does the math and displays the retail price. The program should employ a do-while loop to ask the user if they desire to find the retail price of another product.
2. Write a program. After reading the specifications below, write the pseudo code in the comments before writing the code. The program should ask the user what would they like to do: convert a Fahrenheit temperature to Celsius (F = 9/5 C + 32) or convert a Celsius temperature to Fahrenheit. (C = 5/9(F-32)) The program should validate the input and then, depending on the choice the user makes, ask for a temperature and do the conversion. Use a switch case to handle the choice the user makes. Each choice should call a void function to do the math and display the result to one decimal place. Be sure to test your program.
3. Write a program. After reading the specifications below, write the pseudo code in the comments before writing the code. The program should ask user for the mass and velocity of an object. Validate inputs. Pass inputs to a void function that calculates the kinetic energy of the object. formula is KE = 1/mv2 void function should calculate and display results. Program asks if user wants to calculate the KE of another object and starts over if Yes.
Explanation / Answer
Programs:
1) Pseudo code for wholesale cost and it markup percentage.
BEGIN
GET import cost
GET markup
CALCULATE the wholesale price
CALCULATE the retail price
DISPLAY retail price for one item
SELECT the first bulk number
WHILE the bulk number <= 100
CALCULATE the bulk price
DISPLAY the bulk number
DISPLAY the bulk price
INCREMENT the bulk number
LOOP
END
Program:
#include <iostream>
#include <iomanip>
using namespace std;
double calculateRetail(double wholesaleCost, double markupPercent)
{
double retailPrice;
retailPrice = (wholesaleCost * markupPercent) + wholesaleCost;
return retailPrice;
}
int main()
{
double wholesaleCost;
double markupPercent;
double total;
double calculateRetail (double, double);
//Enter Wholesale Price
cout << "Enter wholesale Price: $";
cin >> wholesaleCost;
if( wholesaleCost < 0 )
{
cout << "Error invalid wholesale cost...Enter a postive number: $";
cin >> wholesaleCost;
}
//Enter Markup Percentage
cout << "Please Enter markup percent: ";
cin >> markupPercent;
if(markupPercent < 0)
{
cout << "Error invalid markup percentage...enter a postive number ";
cin >> markupPercent;
}
markupPercent = markupPercent * .01;
//This is the function call
total = calculateRetail(wholesaleCost, markupPercent);
cout << fixed << setprecision(2);
cout << "The retail price is $" << total << endl;
cout << endl;
system ("pause");
return 0;
}
2)Pseudocode :
Main module
Write
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.