I was asked to write a program in CodeBlocks. C++ format. I've written the first half of the code but I am using else and if statements. I feel like the code is too long to do a simple calculation. In CodeBlock when you build and run your code, a new terminal window opens (in windows a new console window) and you can enter your inputs there. It is not like eclipse that you enter your inputs in console view. The inputs should be random and the code ran to under and over 20 inches.
You have decided to take on a project outside of the Research Center for a local cabinet-making shop. The owner wants a cost calculator for one of his best-selling products, Hope Chests. For this program, the basic hope chest cost is $150, but options available to the customer can cause the price to increase.. Your program must ask the user the following questions INSIDE a function called “get_dimensions” (pass the arguments into the function by REFERENCE):
After these values have been set by the function, the three arguments are then passed by value to another function called calc_Volume to determine the cubic volume of the Hope Chest. If the calculated cubic volume is greater than 12,000 cubic inches, an additional charge of $50 will be set, and returned by the function, otherwise the additional charge will be set to $0 and returned.
The program will then ask the user if they want a premium chest (made of Oak). Another option (lining) will be asked for, but only for the premium Hope Chest.
The main program will then display the type of Hope Chest (Premium or basic), along with all options chosen (including whether the Cedar Lining was chosen as an option) and the costs for each option. If the cubic volume charge is incurred, that needs to be listed as well.
input validation: Do not accept any values for the dimensions less than 20 inches, nor more than 48 inches for any of the dimensions.
#include<bits/stdc++.h>
using namespace std;
int cal_charge(int basic);
int cal_volume_price(int length,int width,int height);
int main()
{
int res=cal_charge(150);
cout<<"Price of Hope Chest : "<<res<<endl;
}
int cal_charge(int basic)
{
int choose;
cout<<"\nEnter length,width and Height of Hope Chest : \n ";
cout<<"length,width,height must greater than 20 and less than 48 ";
int length, width, height;
cout<<"\nEnter Length : "; cin>>length;
cout<<"\n Enter Width : "; cin>>width;
cout<<"\n Enter Height : ";cin>>height;
cout<<"choose your plan Premier or basic \n";
cout<<"Press 1. for Basic and\n Press 2. for premier\n";
cin>>choose;
if(choose==2)
{
int choose;
cout<<"Press 1 for Made of Oak\n";
cout<<"Press 2 for custom Lining\n";
cin>>choose;
if(choose == 2) { basic+=75;}
}
return basic+cal_volume_price(length,width,height);
}
int cal_volume_price(int length,int width,int height)
{
if(length*width*height>12000) return 50;
else return 0;
}
output screen 1
output screen 2
Description : -
cal_volume function has separated function which return price if volume >12000
cal_charge explore either basic + premimum by choosing your option when pask for pressing , so press right number to get desired result
Get Answers For Free
Most questions answered within 1 hours.