Solved-Project 1- Solution

$35.00 $24.00

Write a C program project1.c that operates as follows. The purpose is to design a custom home by specifying the relevant dimensions and making a few other decisions, and then the program will determine the cost of building this home. The diagram below illustrates the house which will be built on a rectangular lot. You…

You’ll get a: . zip file solution

 

 
Categorys:
Tags:

Description

5/5 – (2 votes)

Write a C program project1.c that operates as follows. The purpose is to design a custom home by specifying the relevant dimensions and making a few other decisions, and then the program will determine the cost of building this home.

The diagram below illustrates the house which will be built on a rectangular lot. You can vary the dimensions of the lot and the house. All linear dimensions will be given in feet, all areas will be calculated in sq ft, and all volumes will be calculated in cu ft. All values are doubles, and all outputs should include two digits past the decimal point (use output format %0.2lf).

Y0

Y1

Y2

Y3

Y4

Y5

Y6

First your program will read the following input values exactly in the order shown:

  • Horizontal dimensions X0, …, X9 and vertical dimensions Y0, …, Y7 in feet. All relevant dimensions of the house and lot can then be determined from the diagram. For example, the laundry has dimensions X2 by Y4, and the foyer has dimensions X5 by Y5. The only exception is that the sidewalk always has width 4, regardless the value of X5.

  • Ceiling height Z in feet.

  • Siding cost in dollars/sq ft. For example, vinyl=5, wood=10, brick=15, stucco=20, stone=30.

  • Roofing cost in dollars/sq ft. For example, asphalt=3, wood=6, metal=9, clay=12, slate=15.

  • Deck cost in dollars/sq ft. Typically 15 to 35 depending on type of wood and the deck design.

  • Appliance style indicator. 1=aluminum, 2=stainless, 3=custom panels, etc.

  • Flooring costs in dollars/sq ft for bathrooms, bedrooms, dining room, family room, foyer, halls, kitchen, laundry, and living room. For example, vinyl=8, carpet=10, hardwood=20, tile=25.

Next your program will calculate and output the following values exactly in the order shown. Your program’s output will be read and graded by another computer program (a grading script), which may not be able to recognize your output if you display it in the wrong order or label it incorrectly.

  • Lot size in sq ft.

  • House area in sq ft. Includes garage and porches.

  • Interior area in sq ft. Does not include garage and porches.

  • Interior volume in cu ft. Living space that will be heated and cooled.

  • Exterior wall length in feet. Perimeter along the boundary of the interior area.

  • Exterior wall area in sq ft. Assume exterior height is Z+2. Wall area includes doors and windows, so do not deduct for these.

The remaining outputs are in dollars and cents. Each category includes cost of materials and labor.

  • Lot cost at $4.00/sq ft based on lot size.

  • Site prep at $1.00/sq ft based on lot size.

  • Foundation cost at $10.00/sq ft based on house area.

  • Framing cost at $1.50/cu ft based on house area and exterior height.

  • Total siding cost based on siding cost (dollars/sq ft) and exterior wall area (sq ft).

  • Total roofing cost based on roofing cost (dollars/sq ft) and house area (sq ft).

  • Cost of doors and windows at $8.00 times house area.

  • Plumbing and fixtures at $5.00 times house area.

  • Electrical and lighting at $5.00 times house area.

  • Heating and A/C at $0.50 times interior volume.

  • Insulation at $0.25 times interior volume.

  • Drywall at $0.50 times interior volume.

  • Painting at $0.40 times interior volume.

  • Cabinets at $5.00 times interior area.

  • Appliances allowance at $5000.00 times the appliance style indicator.

  • Total flooring cost based on flooring cost (dollars/sq ft) and room area (sq ft). Sum over all rooms of the house.

  • Security system at $0.75 times house area.

  • Concrete at $4.00/sq ft for driveway, patio, sidewalk, and porches.

  • Total deck cost based on deck cost (dollars/sq ft) and deck area (sq ft).

  • Landscaping at $1.00/sq ft based on lawn area.

  • Sprinkler system at $0.30/sq ft based on lawn area.

  • Subtotal is the sum of all above dollar amounts.

  • Contractor adds 20% of subtotal for expenses, overhead, commissions, profit, etc.

  • Total cost.

Here is an example that shows input values and corresponding output values. Your program’s outputs should be labeled and formatted exactly as shown below.

Input:

Output:

4012841681641240

Lot size = 20160.00

24206101012440

House area = 3360.00

9

Interior area = 2800.00

10

Interior volume = 25200.00

3

Exterior wall length = 264.00

15

Exterior wall area = 2904.00

1

25102020201025820

Lot cost = 80640.00

Site prep = 20160.00

Foundation = 33600.00

Framing = 55440.00

Siding = 29040.00

Roofing = 10080.00

Doors and windows = 26880.00

Plumbing = 16800.00

Electrical = 16800.00

Heating and A/C = 12600.00

Insulation = 6300.00

Drywall = 12600.00

Painting = 10080.00

Cabinets = 14000.00

Appliances = 5000.00

Flooring = 48560.00

Security system = 2520.00

Concrete = 7104.00

Deck = 7200.00

Landscaping = 14720.00

Sprinkler system = 4416.00

Subtotal = 434540.00

Contractor = 86908.00

Total = 521448.00

Your program must read from standard input (scanf), and it must write to standard output (printf). When grading, we might redirect the input from a file, or redirect the output to a file. But your program will not be aware of this. To save typing when testing your program, you can do this too. Create an input file (such as input1.txt) that contains all the input values. Then run your program as follows:

./a.out < input1.txt

./a.out < input1.txt > output1.txt

The first command will display your program’s output on the screen as usual.

The second command would instead write this output to the file output1.txt.

Please carefully read the following requirements:

  • You must do your own work. You must not borrow any code from any other person, book, website, or any other source. You also must not share your code with any other person, or post it on any website. We run plagiarism detection software on every project. So if you violate these rules, you may receive an invitation to the dean’s office to discuss the penalties for academic misconduct.

  • Make sure your program runs properly on the cs-intro.ua.edu server. Your program will be graded on that system using this command: gcc project1.c –Wall –lm –std=c99. In particular, make sure your program initializes the values of all variables when they are declared or allocated. Otherwise it might behave differently on Linux than it does on a PC or Mac.

  • Compress your project into a zip file that contains your C program source file. Right-click (or secondary click) on your project directory, and then (depending on your operating system) select either the Compress option or Send To Compress from the popup menu. Finally upload your .zip file that contains your .c file for this project to Blackboard.

  • If you violate the above requirements such that it breaks our grading script, your project will be assessed a significant point deduction, and extreme or multiple violations may cause the project to be considered ungradable.

  • Every semester many students lose some points because they don’t follow all the instructions. So please read and follow all the project specifications precisely to prevent losing points unnecessarily. If anything is unclear, please ask for clarification well before the project is due. Please pay particular attention to input and output formats.

  • Submit your project on Blackboard by the due date (11:59pm Friday). There is a grace period of 24 hours (until 11:59pm Saturday). Projects submitted on Sunday will be assessed a late penalty of 5% per hour. No projects will be accepted after Sunday. Once it is graded, your project score will be posted on Blackboard and the results of the grading script will be sent to your Crimson email account.

  • Double-check and triple-check your submission when you submit it. Errors discovered later cannot be fixed and resubmitted after the project is graded. Projects will not be re-graded unless an error is found in the grading script or in the input/output files that are used during grading.