subject
Computers and Technology, 04.01.2021 15:50 adi47

#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 problem?

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 24.06.2019 13:30
Type the correct answer in the box. spell all words correctly. what is the default margin width on all four sides of a document? by default, the document has a margin on all four sides.
Answers: 1
question
Computers and Technology, 24.06.2019 18:30
Is a type of bullying that takes place when a person intentionally posts negative information about another that is not true
Answers: 1
question
Computers and Technology, 25.06.2019 06:50
Write a program that will askthe user to enter the amount of a purchase. the program should thencompute the state and county sales tax. assume the state sales tax is4 percent and the county sales tax is 2 percent. the program should displaythe amount of the purchase, the state tax, the county sales tax, the total salestax, and the total of the sale. (which is the sum of theamount of purchase plus the total sales tax). hint: use the value 0.02 torepresent 2 percent, and 0.04 to represent 4 percent.
Answers: 2
question
Computers and Technology, 25.06.2019 08:10
Is a philosophy and a software and system development methodology that focuses on the development, use, and reuse of small, self-contained blocks of codes to meet the software needs of an organization.joint application designextreme programmingrapid application developmentservice-oriented architecture
Answers: 1
You know the right answer?
#include <iostream> using namespace std;

// function prototypes
float get_Pri...
Questions
question
Mathematics, 01.09.2020 19:01
question
Mathematics, 01.09.2020 19:01
question
Mathematics, 01.09.2020 19:01
question
Biology, 01.09.2020 19:01
question
Mathematics, 01.09.2020 19:01
question
Mathematics, 01.09.2020 19:01
question
History, 01.09.2020 19:01
Questions on the website: 13722361