Lawn Supplies


General Statement: Calculate the number of bags of fertilizer, lime, and grass seed needed based on the square footage of the lawn to be treated and seeded.

Input: All data is on a single line. The first integer indicates how many integers follow.

Output: For each lawn, output the number of bags of fertilizer, the number of bags of lime, and the number of bags of grass seed – in that order.
Output the number of bags, followed by the word BAG(S) and then the item type.
All letters are upper case.
Include some white space between outputs.
The output is to be formatted exactly like that for the sample output given below.

Assumptions: The area value is in the range 1..30000.

Discussion: You must buy whole bags, and you cannot buy less than the square footage requires for coverage.

Coverage Factors:
50# bag fertilizer covers 5000 square feet
40# bag of lime covers 2000 square feet
5# bag of grass seed covers 1000 square feet

Sample Input:
3 13000 4575 10000

Sample Output:
3 BAG(S) FERTILIZER
7 BAG(S) LIME
13 BAG(S) SEED

1 BAG(S) FERTILIZER
3 BAG(S) LIME
5 BAG(S) SEED

2 BAG(S) FERTILIZER
5 BAG(S) LIME
10 BAG(S) SEED

Solutions :

#include <stdio.h>

int main ()
{
    int dataset;
    scanf ("%d", &dataset);

    while ( dataset-- ) {
        int input;
        scanf ("%d", &input);

        int count = input / 5000;

        if ( input % 5000 )
            count++;

        printf ("%d BAG(S) FERTILIZER\n", count);

        count = input / 2000;

        if ( input % 2000 )
            count++;

        printf ("%d BAG(S) LIME\n", count);

        count = input / 1000;

        if ( input % 1000 )
            count++;

        printf ("%d BAG(S) SEED\n\n", count);
    }

    return 0;
}

One thought on “Lawn Supplies

  1. #include
    int main(){
    int area, fertilizer,lime,seed;
    int i,x;
    printf(“please enter the number of inputs: “);
    scanf(“%d”,&x);
    for(i=1;i<=x;i++){
    printf("please enter the area: ");
    scanf("%d",&area);
    if(area%5000!=0){
    fertilizer=(area/5000)+1;}
    else{fertilizer=area/5000;}
    printf("%d BAGS OF FERTILIZER.\n",fertilizer);
    if(area%2000!=0){
    lime=(area/2000)+1;}
    else{lime=area/2000;}
    printf("%d BAGS OF LIME.\n",lime);
    if(area%1000!=0){
    seed=(area/1000)+1;}
    else{seed=area/1000;}
    printf("%d BAGS OF FERTILIZER.\n",seed);
    }
    return 0;
    }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s