subject
Mathematics, 04.01.2021 15:50 neonaandrews10

#include <iostream> using namespace std;

// function prototypes
float get_Price();
int get_Type();
void tax(float, int);

// start main function
int main() {
float price = 0; // should > 0

int type = 0; // 1 -> Electronic
// 2 -> Sports & Outdoor
// 3 -> Vaccine

price = get_Price;
type = get_type();

cout << "Price before tax = " << price << "\n\n";
tax(price, type);
cout << "Total price after tax = " << price << '\n';

return 0;
}

// start new user-defined functions
void get_Price() {
float p = 0;

while (p < 0) {
cout << "Item price (RM): ";
cin >> p;
}

return p;
}

float get_Type() {
int t == 0;

do {
cout << "\n";
cout << "1 -> Electronic\n";
cout << "2 -> Sports & Outdoor\n";
cout << "3 -> Vaccine\n";
cout << "Item type (1,2,3): ";
cin >> t;
} while (t > 1 || t < 3);

cout << "\n";
return t;
}

// tax is based on item types as follows:
// 1 -> Electronic => 5%
// 2 -> Sports & Outdoor => 3%
// 3 -> Vaccine => 1%
void tax(float p, int t) {
float tax = 0;
switch (t) {
case 1: tax = p * 5 / 100; break;
case 2: tax = p * 3 / 100;
case 3: tax = p * 1 / 100;
}

cout << "Tax cost = " << tax << "\n";
p += tax;
}

What's problem?

ansver
Answers: 1

Other questions on the subject: Mathematics

image
Mathematics, 21.06.2019 17:30, Ezasha
F(x)= 4x g(x) =x-1 what is f(x) divided by g(x)
Answers: 2
image
Mathematics, 21.06.2019 23:40, Tabbicat021
If f(x) = -5x + 1 and g(x) = x3, what is (gºf)(0)? enter the correct answer
Answers: 1
image
Mathematics, 22.06.2019 02:50, JS28boss
How do you find p(a and b) if a and b are independent events for two or more actions, such as tossing a coin twice and finding p(heads and heads)? 2. how do you find p(a or b) if a and b are independent events for one action, such as spinning a four-color spinner once and finding p(red or blue)?
Answers: 1
image
Mathematics, 22.06.2019 04:00, jamesgraham577
Which elements in the set are integers? –8, 3⁄4, √ 18 , 0, √ 16 , 5, –2⁄7, 6 a. –8, 0, 5, 6 b. –8, 0, √ 16 , 5, 6 c. 3⁄4, √ 18 , √ 16 , 5, –2⁄7 d. –8, 0, √ 18 , 5, 6
Answers: 1
You know the right answer?
#include <iostream> using namespace std;

// function prototypes
float get_Pri...

Questions in other subjects:

Konu
Mathematics, 07.06.2021 07:00