Hi,
Again, thanks for all of the help... But a new problem has arisen, and I don't quite know how to go about it. (Like I mentioned earlier, we have no book, and some things are very unclear in this class... The professor seems to be of little help sometimes.)
Alright, I'll restate the problem:
Problem: Write a program that takes the length and width of a rectangular yard and the length and width of a rectangular house situated in the yard. The program should calculate and display the time required to cut the grass at the rate of two square feet a second.
...The one requirement that I didn't understand was having only two inputs. ...There are four variables, yet, our professor only wants two input functions. ...Meaning that he wants the length and width of the yard put in in the same input function, and the length and the width of the house to be put into the same input function as well.
...How would I go about this?
I don't want anyone to write out any code for me, I'd just like to figure it out. If anyone could link me to a website that explains this, or can explain it to me, I'd be very grateful.
This is the working program that I have so far:
Code:
#include <stdio.h>
#define CUT_RATE 2.0
#define MINUTE 60
int main( void )
{
double lyard; /*INPUT: length of yard*/
double wyard; /*INPUT: width of yard*/
double lhouse; /*INPUT: length of house*/
double whouse; /*INPUT: width of house*/
double Ayardt; /*OUTPUT: total area of yard w house*/
double Ahouse; /*OUTPUT: area of house*/
double Ayard; /*OUTPUT: area of yard wout house*/
double timeS; /*OUTPUT: total time required to cut grass at given speed IN SECONDS*/
double timeM; /*OUTPUT: total time required to cut grass at given speed IN MINUTES*/
/*Enter dimensions of yard and house*/
printf("Enter the length of the rectangular yard in feet> ");
scanf("%lf", &lyard);
printf("Enter the width of the rectangular yard in feet> ");
scanf("%lf", &wyard);
printf("Enter the length of the rectangular house in feet> ");
scanf("%lf", &lhouse);
printf("Enter the width of the rectangular house in feet> ");
scanf("%lf", &whouse);
/*Calculate the total area of the yard*/
Ayardt = lyard * wyard;
/*Calculuate the area of the house*/
Ahouse = lhouse * whouse;
/*Calculate the area of the yard without the house*/
Ayard = Ayardt - Ahouse;
/*Calculate the total time req to cut lawn SECONDS*/
timeS = Ayard / CUT_RATE;
/*Calculuate total time req to cut lawn MINUTES*/
timeM = timeS / MINUTE;
/*Display the area of the yard without the house and the total time req to cut yard*/
printf("Total area of yard without house: %0.2f \nTotal cutting time of yard: %0.2f seconds, or %0.2f minutes\n", Ayard, timeS, timeM);
return 0;
}