Question

write in c program. In this problem you will calculate the area of a house and...

write in c program.

In this problem you will calculate the area of a house and compare it with another house to see

which one is bigger. House1 vs. House2

We need to have a struct that has width and length in it. This struct represents a rectangular

room. From room we need to define:

Bathroom, Livingroom, Bedroom and Kitchen.

An example of the struct and Bathroom, Livingroom, Bedroom and Kitchen is shown below.

Also, it is shown how to set value of Bathroom Length and Width- values are assumed in feet.

House area is in Square Feet (sqrft) and can be calculated by adding all room areas together in

sqrft.

Struct room {

Length;

Width:

};

Struct room Bathroom1

, Livingroom1,

Kitchen1, Bedroom1;

Bathroom1.Length=10;

Bathroom1.Width=7;

Now Given:

House1 is comprised of:

Bedroom1 (L=15,W=10)

Bathroom1 (L=10,W=7)

Kitchen1(L=15, W= 10)

Livingroom1 (L=25,W=20)

House2 is comprised of:

Bedroom2_1 (L=10, W=10)

Bedroom2_2(L=10, W=12)

Kitchen2(L=16,W=10)

Livingroom2 (L=15,W=12)

Calculate each House area and determine which is the larger House and report it promptly.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

#include <stdio.h>

struct room {

int Length;

int Width;

};

int main()
{
struct room Bathroom1

, Livingroom1,
  
Kitchen1, Bedroom1;
  
Bedroom1.Length = 45;
Bedroom1.Width = 10;
Bathroom1.Length = 10;
Bathroom1.Width = 7;
Kitchen1.Length = 15;
Kitchen1.Width = 10;
Livingroom1.Length = 25;
Livingroom1.Width = 20;
  
int house1TotalArea = Bedroom1.Length * Bedroom1.Width +
Bathroom1.Length * Bathroom1.Width +
Kitchen1.Length * Kitchen1.Width +
Livingroom1.Length * Livingroom1.Width;
  
struct room Bathroom2

, Livingroom2,
  
Kitchen2, Bedroom2;
  
Bedroom2.Length = 10;
Bedroom2.Width = 10;
Bathroom2.Length = 10;
Bathroom2.Width = 12;
Kitchen2.Length = 16;
Kitchen2.Width = 10;
Livingroom2.Length = 15;
Livingroom2.Width = 12;
  
int house2TotalArea = Bedroom2.Length * Bedroom2.Width +
Bathroom2.Length * Bathroom2.Width +
Kitchen2.Length * Kitchen2.Width +
Livingroom2.Length * Livingroom2.Width;
  
if(house1TotalArea > house2TotalArea)
{
printf("House 1 : %d sqft has a greater area than House 2 : %d sqft",house1TotalArea,house2TotalArea);
}
else
{
printf("House 2 : %d sqft has a greater area than House 1 : %d sqft",house2TotalArea,house1TotalArea);
}
  
  
}

OUTPUT:

Add a comment
Know the answer?
Add Answer to:
write in c program. In this problem you will calculate the area of a house and...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a java program that computes the total surface area of a rectangular prism. There are...

    Write a java program that computes the total surface area of a rectangular prism. There are six sides, so the area of all six sides has to the summed to get the total area. The program should ask the user to enter the length (L), width (W) and the height )H) for the object in inches. Create a separate method from the main to calculate the area (name the method calcArea). The output of calcArea will return a double. Output;...

  • please answer all C. 2. What rectangle has the smallest perimeter, for a given area? Suppose...

    please answer all C. 2. What rectangle has the smallest perimeter, for a given area? Suppose you want a rectangle with area 200. What choice of length L and width W will give the smallest perimeter? a. Sketch a rectangle and label it as having length L and width W. b. Write the area in terms of length and width: A = Write the perimeter in terms of length and width: P = d. If L = 200 and W...

  • A rectangular room has an area of 400 square foot. The length is 7 feet less than twice the width. How do you find the dimensions of the room?

    A rectangular room has an area of 400 square foot. The length is 7 feet less than twice the width. How do you find the dimensions of the room?

  • Pólya's Principle Step 1: Understand the Problem 1. Describe in detail what you understand the problem...

    Pólya's Principle Step 1: Understand the Problem 1. Describe in detail what you understand the problem to be. In other words, what problem will you need to solve? Is there enough information to enable you to find a solution to your problem? Show your work here: (10 points) 2. Discuss different ways to construct the room that will be painted. Are there any restrictions on where the window and door will be located? Will the overall amount of paint that...

  • Use C++ to implement a program uses objected oriented programming to calculate the area of a...

    Use C++ to implement a program uses objected oriented programming to calculate the area of a rectangle. The program should create a Rectangle class that has the following attributes and member functions: Attributes: width and length Member functions: setWidth(), setLength(), getWidth() , getLength(), getArea() Where width and length are the respect width and length of a Rectangle class. The setWidth() and setLength() member function should set the length and width, the getWidth(), getLenght(), and getArea() member function should get the...

  • I need a c++ visual basic program that will. Carpet Calculator. This problem starts with the...

    I need a c++ visual basic program that will. Carpet Calculator. This problem starts with the FeetInches class that is provided in the course Content area on the assignment page for this week. This program will show how classes will interact with each other as data members within another class. Modify the FeetInches class by overloading the following operators which should all return a bool. <= >= != Next add a copy constructor to the FeetInches class and a multiply...

  • program language: python 3 Purpose: Solve a problem by writing multiple functions that perform different subtasks,...

    program language: python 3 Purpose: Solve a problem by writing multiple functions that perform different subtasks, and combining their use to solve a larger problem. Also to practice documenting functions. Degree of Difficulty: Moderate Your task is to compute the cost of renovating the flooring in a rectangular room. This includes replacing the carpet and and the baseboards. Your task is to write a Python program that calculates and the cost of the renovation. To accomplish this, you will need...

  • In the code (C++) below, if you input 2 as length and 4 as width, the...

    In the code (C++) below, if you input 2 as length and 4 as width, the output is: Enter the rectangle's length: 2 Enter the rectangle's width: 4 Length: 2 | Width: 4 | Area: 8 | Perimeter:12 We worked on this code during class, but there were some things that I did not understand. 1) how does compiler read"l" as length, "w" as width, etc.? I thought you had to update it first, like "w=width." 2) i thought you...

  • I need help with the C++ for the following problem: Write a program uses objected oriented...

    I need help with the C++ for the following problem: Write a program uses objected oriented programming to calculate the area of a rectangle. The program should create a Rectangle class that has the following attributes and member functions: Attributes: width and length Member functions: setWidth(), setLength(), getWidth() , getLength(), getArea() Where width and length are the respect width and length of a Rectangle class. The setWidth() and setLength() member function should set the length and width, the getWidth(), getLenght(),...

  • Write this program using python. In your program, when you prompt users for values, only prompt...

    Write this program using python. In your program, when you prompt users for values, only prompt them to enter one value at a time. Here is a sample of what your program should look like. Sample Program Run (User input in bold) What is the length of the room (in feet)? 50 What is the width of the room (in feet)? 30 What is the length of the table (in feet)? 8 What is the width of the table (in...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT