Convert Matlab code into "C" code

Code Description:
C Code : Convert the Matlab code solution or develop your own solution into a C program that prompts for and accepts input data from the keyboard, performs calculations with the input data, and display formatted results to the screen. The program needs to accept input from the keyboard one or more walls of a building (width and height in m) and if the wall has a door opening, prompt for the door dimensions (width and height in m). Given you are collecting many walls associated with a building, ensure you prompt for and store the building address or description and keep track of the total quantities of timber required and the total costs of the entire building timber requirements. The program must display appropriate messages before accepting input data and perform any error checking and report errors or incorrect input. If an error is detected, the user should be notified of the error and the program displays informative, appropriate error messages then re-prompt the user to enter the data again until it is within the constraints. The results must be displayed in a readable format with messages indicating what each of the results represents. Output should include the quantity of timber required expressed in the lengths entered for the wall dimensions. When calculating the timber lengths, try to calculate the least amount of timber required.
An example of the program flow is as follows:
                        Enter a new building > y
Building Address > 25 High Street, Belmont
Enter a Wall? > y
Wall ID > 1
Wall width > 4.5
Wall height > 2.5
Structural Pine (45*90mm)
Top Plate :    1 * 4.5m
Bottom Plate : 1 * 4.5m
Wall Studs : 11 * 2.7m
Noggins : 1 * 4.2m
Total timber : 42.90m
Total cost : (42.90 * $5.52) $236.81
Enter a Door/Window > n
Enter a Wall? > y
Wall ID > 2
Wall width > 3.5
Wall height > 2.5
Structural Pine (45*90mm)
Top Plate :    1 * 3.6m
Bottom Plate : 1 * 3.6m
Wall Studs : 11 * 2.7m
Noggins : 1 * 3.3m
Total timber : 34.80m
Total cost : (34.80m * $5.52) $192.10
Enter a Door/Window > n
Enter a Wall? > n
Total timber requirements for 25 High Street, Belmont
Total timber : 77.70m
Total cost : (77.70m * $5.52) $453.03

GOAL: Calculate and display the timber required to build many walls of max width of 5.4m with a door or window with input error checking. For a D grade you must demonstrate you can create and use appropriate functions within your code.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

// The following Matlab code calculates the quantity and cost of structural
// timber required to constract walls with or without openings entered by the
// user.Store the building ID and allow unlimited walls to be entered.
// After a wall has been entered, calculate the timber required, the total
// cost, and output the information
#define STUD_WIDTH 0.045
#define TIMBER_COST 5.52
#define INC 0.3
#define MAX_WALL_WIDTH 5.4
#define MAX_WALL_HEIGHT 3.0

float get_nearest_length(float length);
float round_up(float value, int decimalPlaces);
void clearInputBuffer();

int main()
float wall_width = 0.0;...

By purchasing this solution you'll be able to access the following files:

for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats