Answer to Question #11264 in C++ for Lloyd Lim

Question #11264
Assume you are looking to buy a house in a new development. After looking at various models, the three models they like are majestic, split-entry, and single-story.The builder gave them the base price and the finished area in square meters of three models. They want to know the model(s) with the least price per square feet. Write a program that accepts as input the base price and the finished area in square meters of the three models. The program outputs the model(s) with the least price per square meter.
1
Expert's answer
2012-07-05T07:27:40-0400
// Q.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <string>
#include<stdio.h>
using namespace std;
struct house{
string type;
float cost;
float squaremeter;
};

int main(){
house h[20];
int ch=0;
int coutnofhouse=0;
for(int i=0;i<3;i++){
printf("1 - Majestic
");
printf("2 - Split-entry
");
printf("3 - Single-story
");
printf("0 - Show information
");
printf("Select model: ");
scanf("%d",&ch);
switch(ch){
case 1:
h[coutnofhouse].type="Majestic";
break;
case 2:
h[coutnofhouse].type="Split-entry";
break;
case 3:
h[coutnofhouse].type="Single-story";
break;
}
printf("Enter the base price: ");
scanf("%f",&h[coutnofhouse].cost );
printf("Enter the finished area in square meters:
");
scanf("%f",&h[coutnofhouse].squaremeter);
coutnofhouse++;
}
printf("Model price per square meter
");
for(int i=0;i<3;i++){
printf("%s ",h[i].type.c_str());
printf("%.2f
",h[i].cost/h[i].squaremeter);
}
int i=0;
scanf("%d",i);

}

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

Assignment Expert
10.07.12, 14:12

You're welcome. We are glad to be helpful. If you really liked our service please press like-button beside answer field. Thank you!

Lloyd Lim
08.07.12, 15:51

Thanks a lot:)

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS