Mathematics
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?

answer
Answers: 1

Other questions on the subject: Mathematics

image
Mathematics, 21.06.2019 12:50, dbn4everloved
What is the equation of the linear function represented by the table?
Answers: 1
image
Mathematics, 21.06.2019 17:00, KHaire2077
In a sample of 2023 u. s. adults, 373 said franklin roosevelt was the best president since world war ii. two u. s. adults are selected at random from the population of all u. s. adults without replacement. assuming the sample is representative of all u. s. adults, complete parts (a) through (d). (a) find the probability that both adults say franklin roosevelt was the best president since world war ii. the probability that both adults say franklin roosevelt was the best president since world war ii is (round to three decimal places as needed.) (b) find the probability that neither adult says franklin roosevelt was the best president since world war ii. the probability that neither adult says franklin roosevelt was the best president since world war ii is (round to three decimal places as needed.) (c) find the probability that at least one of the two adults says franklin roosevelt was the best president since world war ii. the probability that at least one of the two adults says franklin roosevelt was the best president since world war ii is (round to three decimal places as needed.) (d) which of the events can be considered unusual? explain. select all that apply. the event in part left parenthesis a right parenthesis is unusual because its probability is less than or equal to 0.05. the event in part (b) is unusual because its probability is less than or equal to 0.05. none of these events are unusual. the event in part (c) is unusual because its probability is less than or equal to 0.05.
Answers: 3
image
Mathematics, 21.06.2019 17:30, paiged2003
The jewelry store is having a sale. necklaces that were regularly priced at $23.50 are on sale for $18.80. what is the percentage of decrease in the price of necklaces?
Answers: 1
image
Mathematics, 21.06.2019 19:00, william03300
Aflower has 26 chromosomes. to create a new flower, how many would a sperm cell have what is called?
Answers: 1
Do you know the correct answer?
#include <iostream> using namespace std;

// function prototypes
float get_Pri...

Questions in other subjects:

Konu
Mathematics, 22.06.2020 02:57
Konu
Physics, 22.06.2020 02:57