Homework2-3

# Homework2-3 - scanf"%d"&Lawn_width...

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

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");

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: scanf("%d", &Lawn_width); printf("Enter the total length of your house. \n"); scanf("%d", &Home_length); printf("Enter the total width of your house. \n"); scanf("%d", &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 > 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("It will take %d seconds to mow your yard.\n", c); printf("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",f, d, e); return (0); }...
View Full Document

## This note was uploaded on 08/06/2008 for the course EGR 261 taught by Professor Parikh during the Spring '08 term at Grand Valley State.

### Page1 / 2

Homework2-3 - scanf"%d"&Lawn_width...

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

View Full Document
Ask a homework question - tutors are online