Question

In: Computer Science

STATEMENT OF PROBLEM A developer is building houses in a new neighborhood. She offers 3 house...

STATEMENT OF PROBLEM

A developer is building houses in a new neighborhood. She offers 3 house plans: “Montgomery”, “Kettering”, and “Saxon”   Although all the windows are the same, each house plan requires a different number of windows: the Montgomery takes 20 windows, the Kettering 15, and the Saxon 12.  

She wants you to design a programming solution that will allow her to enter the number of houses she plans to build of each model and have the program display the total number of windows she should order for the neighborhood. She wants to order an extra 1% to allow for breakage and theft. Also, you can only order whole numbers of windows so always truncate the decimal portion of the result and add 1.

Sample screen: (This is an example of what your screen might look like while the program is running.)   Note: don't worry if your expected output is off by +/- 1 window. For example, it is OK if the last line in the display below says to order 289, 290, or 291 windows. We haven't covered some of the techniques for resolving rounding issues.

This is my code below. It's an entry-level course and I'm following her instructions the best I can but my code will output '0'. We are programming in C.

/* PREPROCESSOR COMMANDS */
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <stdio.h>
/* MAIN PROCESSING CONTROL */
int main()
{
   /* VARIABLE DECLARATIONS */
   double MontgomeryHouses; /* The number of windows in Montgomery Houses */
   double KetteringHouses; /* The number of windows in Montgomery Houses */
   double SaxonHouses; /* The number of windows in Montgomery Houses */
   double WindowsRequired; /* The number of windows required for all houses */

   /* ALGORITHM */
   printf("\nHow many Montgomery Houses will you build: ");
   fflush(stdin);
   scanf("\n%d", &MontgomeryHouses);   
   printf("\nHow many Kettering houses will you build: ");
   fflush(stdin);
   scanf("\n%d", &KetteringHouses);
  
   printf("\nHow many Saxon houses will you build: ");
   fflush(stdin);
   scanf("\n%d", &SaxonHouses);
  
   /* CALCULATE NUMBER OF WINDOWS */
   MontgomeryHouses = 20;
   KetteringHouses = 15;
   SaxonHouses = 12;
   WindowsRequired = MontgomeryHouses + KetteringHouses + SaxonHouses

   /* DISPLAY */;
   printf("\nYou should order %d", WindowsRequired);
   fflush(stdin);
   getchar();
  
   /* PAUSE */
   fflush(stdin);
   getchar();
   return 0;
}
/* END OF FILE */

Solutions

Expert Solution

/*The C++ program that promtps user to enter double type values and store the values in the variables and then sum the values. Then print the result on console output.*/
//main.cpp
/* PREPROCESSOR COMMANDS */
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <stdio.h>
/* MAIN PROCESSING CONTROL */
int main()
{
/* VARIABLE DECLARATIONS */
double MontgomeryHouses=0; /* The number of windows in Montgomery Houses */
double KetteringHouses=0; /* The number of windows in Montgomery Houses */
double SaxonHouses=0; /* The number of windows in Montgomery Houses */
double WindowsRequired=0; /* The number of windows required for all houses */

/* ALGORITHM */
printf("\nHow many Montgomery Houses will you build: ");
/*Note : use %lf for format specifier for reading double type variables
from user*/
scanf("%lf", &MontgomeryHouses);   
/*fflush function clear the buffer(temporary storage space) data*/
fflush(stdin);

printf("\nHow many Kettering houses will you build: ");   
/*Note : use %lf for format specifier for reading double type variables
from user*/
scanf("%lf", &KetteringHouses);
fflush(stdin);


printf("\nHow many Saxon houses will you build: ");
/*Note : use %lf for format specifier for reading double type variables
from user*/
scanf("%lf", &SaxonHouses);
fflush(stdin);
  
/* Sum the values stored in the variables and assign the results to the WindowsRequired*/
WindowsRequired = MontgomeryHouses + KetteringHouses + SaxonHouses

/* print the WindowsRequired value on console output */;
printf("\nYou should order %lf", WindowsRequired);
  
/* PAUSE */
getchar();
return 0;
}
/* END OF FILE */

Sample Output:


Related Solutions

A developer is going to build a new commercial building in Kowloon Tong. The features of...
A developer is going to build a new commercial building in Kowloon Tong. The features of the building are described as follows: Number of storey: 25 floors Floor areas: approx. 600m2 (each floor) Core areas: approx. 100m2 (each floor) G/F to 2/F: Restaurant premises (40% of the UFA); Retail establishments (60% of the UFA) 3/F to 25/F: Office premises Note: UFA denotes Usable Floor Area i ) Calculate the total cooling load for a given building. This part fulfills the...
Java language please Problem There are N houses for sale. The i-th house costs Ai dollars...
Java language please Problem There are N houses for sale. The i-th house costs Ai dollars to buy. You have a budget of B dollars to spend. What is the maximum number of houses you can buy? Input The first line of the input gives the number of test cases, T. T test cases follow. Each test case begins with a single line containing the two integers N and B. The second line contains N integers. The i-th integer is...
A software developer has created a new dating app that she thinks users will prefer over...
A software developer has created a new dating app that she thinks users will prefer over current options. She samples 260 millennials, and randomly splits them into 2 evenly-sized separate samples: the New Dating App Group and the Tinder Group. The dependent variable is self-reported satisfaction of the app on a 1-10 scale. Choose the best statistical test for this research design. A. Repeated Measures ANOVA B. Correlation C. Independent measures t-test D. Regression
Problem Set 2: A product developer wanted to know the preferred advertising strategy for a new...
Problem Set 2: A product developer wanted to know the preferred advertising strategy for a new toothpaste, and if it differs among three target demographic groups: 12-24, 25-40, and 40-60 year olds. There were two versions of advertisements for the toothpaste. Each person indicated their favorite version of the advertisement, as indicated in the table below. Did the preferred advertisement version differ by age group? (Note –conclusions may not be a good reflection of the data due to the small...
Ella purchases a new house for $400,000. She put 20% down and will finance the rest...
Ella purchases a new house for $400,000. She put 20% down and will finance the rest over 30 years at 4.5%. What is her monthly payment? Group of answer choices $1,721.35. $1,621.4 $405.34 $1,635.98.
Problem 3 An entity entered into a construction contract to build a condo building at a...
Problem 3 An entity entered into a construction contract to build a condo building at a fixed price of $54,000,000. Construction started in 20x0 and ended in 20x3. Data on the contract is as follows (in ‘000’s): 20x0 20x1 20x2 20x3 Costs incurred during the year $ 6500 19500 25000 5800 Estimated costs to complete 38500 26000 6500 - Billings 18000 18000 - 18000 For each of the parts below, prepare the ‘mini’ income statement for the project for each...
Emily Morrison purchased a new house for $190,000 and paid $40,000 upfront. How much does she need to borrow to purchase the house?
(Annuity payments)  Emily Morrison purchased a new house for $190,000. She paid $40,000 upfront and agreed to pay the rest over the next 10 years in 10 equal annual payments that include principal payments plus 12 percent compound interest on the unpaid balance. What will these equal payments be?a.  Emily Morrison purchased a new house for $190,000 and paid $40,000 upfront. How much does she need to borrow to purchase the house?
(1) Emily Morrison purchased a new house for ​$100,000. She paid ​$40,000 upfront and agreed to...
(1) Emily Morrison purchased a new house for ​$100,000. She paid ​$40,000 upfront and agreed to pay the rest over the next 20 years in 20 equal annual payments that include principal payments plus 9 percent compound interest on the unpaid balance. What will these equal payments​ be? a.  Emily Morrison purchased a new house for ​$100,000 and paid ​$40,000 upfront. How much does she need to borrow to purchase the​ house​(Round to the nearest​ dollar.) (2) To pay for...
Problem: A university administrator is interested in whether a new building can be planned and built...
Problem: A university administrator is interested in whether a new building can be planned and built on campus within a four-year time frame. He considers the process in two phases. Phase I: Phase I involves lobbying the state legislature and governor for permission and funds, issuing bonds to obtain funds, and obtaining all the appropriate legal documents. Past experience indicates that the time required to complete phase I is approximately normally distributed with a mean of 16 months and standard...
Problem 14-2 Splish Co. is building a new hockey arena at a cost of $2,560,000. It...
Problem 14-2 Splish Co. is building a new hockey arena at a cost of $2,560,000. It received a downpayment of $450,000 from local businesses to support the project, and now needs to borrow $2,110,000 to complete the project. It therefore decides to issue $2,110,000 of 12%, 10-year bonds. These bonds were issued on January 1, 2016, and pay interest annually on each January 1. The bonds yield 11%. Your answer is partially correct. Try again. Assume that on July 1,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT