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

Another question on Mathematics

question
Mathematics, 21.06.2019 18:00
The swimming pool is open when the high temperature is higher than 20∘c. lainey tried to swim on monday and thursday (which was 3 days later). the pool was open on monday, but it was closed on thursday. the high temperature was 30∘c on monday, but decreased at a constant rate in the next 3 days. write an inequality to determine the rate of temperature decrease in degrees celsius per day, d, from monday to thursday.
Answers: 1
question
Mathematics, 21.06.2019 21:30
What is the volume of this container?
Answers: 2
question
Mathematics, 21.06.2019 22:30
Adistribution has the five-number summary shown below. what is the third quartile, q3, of this distribution? 22, 34, 41, 55, 62
Answers: 2
question
Mathematics, 21.06.2019 23:50
How are algebraic expressions evaluated using substitution?
Answers: 1
You know the right answer?
#include <iostream> using namespace std;

// function prototypes
float get_Pri...
Questions
question
Mathematics, 10.10.2020 18:01
question
Mathematics, 10.10.2020 18:01
question
Mathematics, 10.10.2020 18:01
question
History, 10.10.2020 18:01
question
Mathematics, 10.10.2020 18:01
question
Mathematics, 10.10.2020 18:01
Questions on the website: 13722363