Here is the scenerio:
Part A.
Modifying Lab #6 to use a void function ( i.e. it will not return anything.)
First, fix anything you did wrong in Lab#6 to be done correctly.
E.g. using the wrong kind of loops
put in blank lines for readability
break up long "cout" statements into multiple lines
Write a function named "showResults" that will print this message first:
Inside showResults
Then do all of the calculations and printing of output. I.e. put all of that code into the function body of "showResults" and take it all out of "main".
The input values will need to be passed in from "main" into "showResults".
The function "showResults" returns no value.
The input values should NOT be changed inside the function "showResults".
Change "main" to get valid input from a user, call the function "showResults", then after the function executes, "main" asks the user about running again for another set of data.
Run your program with the same values that you used for Lab#6 Part B.
No global variables, must pass parameters!
This is what i had from part b:
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 36 37 38 39 40 41 42
|
#include <iostream>
#include <cmath>
using namespace std ;
int main()
{
std::cout <<"Rebecca Carolina Katz, lab 6 part b\n" ; // endl;;
// Variable declarations
/* float */ double wholesale_cost ; // cost; // *** favour double as the default floating point type
/* float */ double Mark_up_percentage;
/* float */ double Sales_tax_rate;
char run_the_program_again ; // *** added
do
{
do
{
cout << "Enter Wholesale Cost:";
cin >> wholesale_cost;
if (wholesale_cost <= 0)
cout << "Invalid.Wholesale cost must be > 100 and a positive number" << endl;
} while (wholesale_cost <=0) ;
do
{
cout << "Enter Mark up percentage:";
cin >> Mark_up_percentage;
if ((Mark_up_percentage > 1) || (Mark_up_percentage < 0.0))
cout << "Invalid.Markup percentage must be < or equal to 100 and must be positive" << endl;
} while ((Mark_up_percentage > 1) || (Mark_up_percentage < 0.0)) ;
do
{
cout << "Enter sales tax rate:";
cin >> Sales_tax_rate;
if ((Sales_tax_rate > 0.15) || ( Sales_tax_rate <= 0.00))
cout << "Invalid.Sales tax rate must be > 0.15 and must be positive" << endl;
} while ((Sales_tax_rate > 0.15) || (Sales_tax_rate <= 0.00)) ;
|