Write a program for a furniture company that determines the price of a table. As
ID: 646146 • Letter: W
Question
Write a program for a furniture company that determines the price of a table. Ask the user to choose 1 for pine, 2 for oak, or 3 for mahogany. The output is the name of the wood chosen as well as the price of the table. Pine tables cost $100, oak tables cost $225, and mahogany tables cost $310. If the user enters an invalid wood code, set the price to 0 (This might be best done in a switch structure). Add a prompt to ask the user to specify a (1) large table or a (2) small table. Add $35 to the price of any large table, and add nothing to the price for a small table (This might be best done in an if
Explanation / Answer
#include <iostream>
using namespace std;
int main(){
double price;
int size;
int option;
cout << "choose 1 for pine, 2 for oak, or 3 for mahogany: ";
cin >> option;
switch(option){
case 1:
price = 100;
cout << "You chose pine and it is of $100" << endl;
break;
case 2:
price = 225;
cout << "You chose oak and it is of $225" << endl;
break;
case 3:
price = 310;
cout << "You chose mahogany and it is of $310" << endl;
break;
default:
price = 0;
}
cout << "(1) large table or a (2) small table: ";
cin >> option;
if(option == 1){
price += 35;
}
else if(option != 2){
cout << "Error: Invalid choice" << endl;
}
cout << "--------------" << endl;
cout << "Receipt " << endl;
cout << "--------------" << endl;
cout << "Actual price of table: " << price << endl;
cout << "Tax: " << 0.06 * price << endl;
cout << "Total: " << price + (0.06 * price) << endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.