63 214
Assignments Done
99,3%
Successfully Done
In July 2018

Answer to Question #54977 in C++ for TamirJadd

Question #54977
pseudo-code for Samantha and Vikas are looking to buy a house in a new development. After looking at various
models, the three models they like are colonial, split-entry, and single-story. The builder gave
them the base price and the finished area in square feet of the three models. They want to know
the model(s) with the least price per square foot. Write a program that accepts as input the base
price and the finished area in square feet of the three models. The program outputs the model(s)
with the least price per square foot.
Expert's answer
Struct Model
{
double model_price;
double model_area;
}

Model& least_price_model(Model& colonial, Model& split_entry, Model& single_story)
{
// Input: 3 models with defined price and area
double price1 = colonial.model_price / colonial.model_area;
double price2 = split_entry.model_price / split_entry.model_area;
double price3 = single_story.model_price / single_story.model_area;
double min_price = min(price1, price2);
min_price = min(min_price, price3);
if (min_price == price1)
return colonial;
else if (min_price == price2)
return split_entry;
else return single_story
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions