One Issue with some simple logic and getting something to print C++ HouseWindowsLab?Ask Questions
c

 Posted on 07/09/2018 7:40:08 AM

Please Help. This simple program is suppose to calculate users inputs for how many of each house they want. Multiply it by the windows each house adds. And apply 1% more windows to the total for spares. Why isn't the spare part working?

#include <stdio.h>

/* MAIN PROCESSING CONTROL */
int main()
{
/* VARIABLE DECLARATIONS */
int MontgomeryHouses; /*20 Windows per a house*/
int KetteringHouses; /*15 Windows per a house*/
int SaxonHouses; /*12 Windows per a house*/
int TotalWindows; /*Total calculation of all windows*/
int SpareWindows; /*How many spare windows if you wanted 1% of total*/ 

/* WINDOWS PER HOUSE ALGORITHM */
printf("\n How many Montgomery Houses do you wish to build? They have 20             windows. ");
scanf("\n%d", &MontgomeryHouses);
fflush(stdin);

printf("\n How many Kettering Houses do you wish to build? They have 15 windows. ");
scanf("\n%d", &KetteringHouses);
fflush(stdin);

printf("\n How many Saxon Houses do you wish to build? They have 12 windows. ");
scanf("\n%d", &SaxonHouses);
fflush(stdin);

/* CALCULATE TOTAL WINDOWS*/
TotalWindows = (MontgomeryHouses * 20) + (KetteringHouses * 15)
        + (SaxonHouses * 12);
SpareWindows = TotalWindows * 0.01;
/* DISPLAY OUTPUT*/
printf("The spare windows needed &d are windows.\n",SpareWindows);
fflush(stdin);  
printf("\nThe total amount of windows needed for all houses are %d windows.\n",TotalWindows);
fflush(stdin);



return 0;
}
/* END OF PROGRAM */

 

Share On: facebook gplus twitter
profile
Asked by Hardik Chaudhary on 07/09/2018 7:40:08 AM Score: 366 points
Add Comment:
Submit

Comments

1 Answer

1 Corrected Answers
Aproved Answers
2
Profile
Answered by Shailesh Chaudhary on Sep 7 2018 7:55AM Score: 501 points

Your logic is totally fine. It is just a tiny syntax error. In this line:

printf("The spare windows needed &d are windows.\n",SpareWindows);

&d should be replaced by %d.

I think you just overlooked it, because the other parts are perfect.

Add Comment:

Post Your Answer

  •  
  •  

Existing Members

Sign in to your account
Email Address
Password
...or Join us
Download, Vote, Comment, Publish.
Full Name
Email Address
I have read and agree to the Terms of Service and Privacy Policy
Please subscribe me to the StoodQ newsletters
Guideline to answer a question:

Useful tips to submit your answer
Please read below guidelines before you submit your answer for question.

  • Read and understand question for which you are submitting your answer.
  • Try to avoid grammatical and spell mistake while answering.
  • Do not post any irrelevant information in your answer.
  • Explain your answer with example or any reference link to help who posted question.
  • If you find irrelevant question, please report it to support. Click here to contact support.
  • You agree to the privacy policy and terms of use to submit any contents.

Note: StoodQ is online developers community which helps developer for their difficulty, lets help them with your value contribution.