Question

I was asked to write a program in CodeBlocks. C++ format. I've written the first half...

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):

  1. The length of the Hope Chest
  2. The width of the Hope Chest
  3. The depth of the Hope Chest

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.

  1. If the customer wants a premium Hope Chest, then a function called calc_Charge will be called, passing the base price of the Hope Chest, the charge for the cubic volume (either $0 or $50 depending on the calculated charge) and the premium charge. All three values will be passed by value. Inside this function, ask the user if they want the custom lining (Cedar). If they do, an additional $75 charge will be added to this chest’s total cost. The function will calculate the charge for the Hope Chest and return it to the main program for display.
  2. If the customer does NOT want the premium version of the Hope Chest, a function called calc_Charge (same name as in option 1) will be called, passing the base price of the Hope Chest and the charge for cubic volume. The function will calculate the charge for the Hope Chest and return it to the main program for display.
  3. You will need to determine if any other arguments are passed into these functions. If there are additional arguments, you must ensure that the argument lists for each of the two functions called calc_Charge are sufficiently different enough for them to still be considered overloaded.

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.

Homework Answers

Answer #1
#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

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a Python program named lastNameVolumes that finds the volumes of different 3 D objects such...
Write a Python program named lastNameVolumes that finds the volumes of different 3 D objects such as a cube, sphere, cylinder and cone. In this file there should be four methods defined. Write a method named cubeVolFirstName, which accepts the side of a cube in inches as an argument into the function. The method should calculate the volume of a cube in cubic inches and return the volume. The formula for calculating the volume of a cube is given below....
Write a C program Design a program that uses an array to store 10 randomly generated...
Write a C program Design a program that uses an array to store 10 randomly generated integer numbers in the range from 1 to 50. The program should first generate random numbers and save these numbers into the array. It will then provide the following menu options to the user: Display 10 random numbers stored in the array Compute and display the largest number in the array Compute and display the average value of all numbers Exit The options 2...
Write a C++ program which consists of several functions besides the main() function. 1)   The main()...
Write a C++ program which consists of several functions besides the main() function. 1)   The main() function, which shall ask for input from the user (ProcessCommand() does this) to compute the following: SumProductDifference and Power. There should be a well designed user interface. 2)   A void function called SumProductDifference(int, int, int&, int&, int&), that computes the sum, product, and difference of it two input arguments, and passes the sum, product, and difference by-reference. 3)   A value-returning function called Power(int a,...
Please write it in c# program please and if possible no arrays only loops Loop Introduction...
Please write it in c# program please and if possible no arrays only loops Loop Introduction Assignment Using the conditions below, write one program that calculates a person’s BMI. Your main() function will call functions 1, 2, and 3. Your program will contain three functions: Function #1: Will ask the user for their weight in pounds and their height in inches.   Your function will convert the weight and height into Body Mass Index (BMI). The formula for converting weight into...
C++. Write a program that draws a rocket shape on the screen based on user input...
C++. Write a program that draws a rocket shape on the screen based on user input of three values, height, width and stages. The type of box generated (i.e.. a hollow or filled-in) is based on a check for odd or even values input by the user for the box height (or number of rows). Here is the general specification given user input for the height of the box..... Draw a hollow box for each stage if the value for...
IN PYTHON Menu: 1. Hotdog. ($2) 2. Salad ($3)  3. Pizza ($2) 4.Burger ($4) 5.Pasta ($7) Write...
IN PYTHON Menu: 1. Hotdog. ($2) 2. Salad ($3)  3. Pizza ($2) 4.Burger ($4) 5.Pasta ($7) Write a menu-driven program for  Food Court. (You need to use functions!) Display the food menu to a user . 5 options Use numbers for the options and for example "6" to exit. Ask the user what he/she wants and how many of it. (Check the user inputs) AND use strip() function to strip your inputs(if needed) Keep asking the user until he/she chooses the exit...
Please provide answer in the format that I provided, thank you Write a program that prompts...
Please provide answer in the format that I provided, thank you Write a program that prompts the user to input a string. The program then uses the function substr to remove all the vowels from the string. For example, if str=”There”, then after removing all the vowels, str=”Thr”. After removing all the vowels, output the string. Your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel. You must...
Python code only! (Do not include breaks or continue functions) Write a program that asks the...
Python code only! (Do not include breaks or continue functions) Write a program that asks the user to enter the amount that they budgeted for the month. A loop should then prompt the user to enter their expenses, one at a time and to enter 0 to quit. When the loop finishes, the program should display the the amount of budget left. (a negative number indicates the user is over budget and a positive number indicates the user is under...
A Cable Company has hired you to write a C++ program that calculates the monthly bill...
A Cable Company has hired you to write a C++ program that calculates the monthly bill for their customers. It must meet the following specifications: The program must first greet the customer. The program must then ask for their name, the number of basic channels packages they’re subscribed to, then the number of premium channel packages they’re subscribed to. The bill is calculated as follows: There is a $75 base fee. The first 3 basic channels packages are free, after...
Assignment #4 – Student Ranking : In this assignment you are going to write a program...
Assignment #4 – Student Ranking : In this assignment you are going to write a program that ask user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT