Homework2-3 - scanf("%d",...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Homework #2 /* * Program by Justin Waters * Inputs: measurements of house and yard * Outputs: time needed to mow the grass at a specific rate * Description: This program allows users to enter measurements of a yard and house, then it will computer the time needed to mow the grass. * */ #include <stdio.h> //standard header file #include <math.h> //math operations int main (void) { int Lawn_width,Lawn_length; //lawn size inputs int Home_width,Home_length; //home size inputs int a,b,c,d,e,f,g; //temp storage for calculations f = 0; //initialize variable /* tells user what the program does*/ printf("\nThis program will calculate the time needed to mow \n your grass after you provide measurements for the house and yard.\n"); /*gets yard and house inputs from user*/ printf("\nInput measurements must be in feet, rounded to nearest whole number.\n"); printf("\nEnter the total length of your yard. \n"); scanf("%d", &Lawn_length); printf("Enter the total width of your yard. \n");
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: scanf(&quot;%d&quot;, &amp;Lawn_width); printf(&quot;Enter the total length of your house. \n&quot;); scanf(&quot;%d&quot;, &amp;Home_length); printf(&quot;Enter the total width of your house. \n&quot;); scanf(&quot;%d&quot;, &amp;Home_width); a = Lawn_length * Lawn_width; //total size of property b = Home_length * Home_width; //total size of house c = (a - b) / 2; //total size of actual grass to be mowed //used if it takes longer than 59 minutes to mow if (c &gt; 3599) { f = c/3600; //finding hours g = c - (f *3600); d = g/60; //finding minutes e = g - (d * 60); //finding seconds } //used if less than 1 hour is needed to mow grass else { d = c/60; //finding minutes e = c - (d * 60); //finding seconds } //printf(&quot;It will take %d seconds to mow your yard.\n&quot;, c); printf(&quot;It will take %d hours, %d minutes, and %d seconds to mow your yard.\nThis was calculated based on a constant mowing speed of 2 ft^2 per second&quot;,f, d, e); return (0); }...
View Full Document

Page1 / 2

Homework2-3 - scanf(&amp;amp;quot;%d&amp;amp;quot;,...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online