Question

In: Computer Science

IN C LANGUAGE You decide you want to build a skate park in your backyard, so...

IN C LANGUAGE

You decide you want to build a skate park in your backyard, so you need to buy a lot of concrete. The good news is, you can get a discount when you buy in bulk. The price of concrete for different grades of concrete per cubic yard is as follows:

  • when grade is either "low" or "cheap"
    • $100 (per cubic yard) for less than 200 cubic yards
    • $95 for between 200 and 400 (including 200 and 400) cubic yards
    • $90 for more than 400 cubic yards
  • when grade is either "high" or "expensive"
    • $150 for less than 250 cubic yards
    • $135 for 250 or more cubic yards

Write a program that calculates the price of an order of concrete when given the grade and quantity.

Notes

  • You can assume valid input.
  • The grader is checking if your output ends with the integer dollar amount (no cents or punctuation).

Examples

What grade of concrete (low/cheap, high/expensive)?
low
How many cubic yards of concrete?
75
The cost is $7500

The answer to the example above is calculated from 75 * $100 (low grade, less than 200 cubic yards) = $7500

What grade of concrete (low/cheap, high/expensive)?
cheap
How many cubic yards of concrete?
75
The cost is $7500
What grade of concrete (low/cheap, high/expensive)?
high
How many cubic yards of concrete?
75
The cost is $11250
What grade of concrete (low/cheap, high/expensive)?
expensive
How many cubic yards of concrete?
75
The cost is $11250

Solutions

Expert Solution

Code:

#include<stdio.h>
#include<string.h>
int main()
{
   int yard;
   char concrete[15];/*Declaring variables*/
   printf("What grade of concrete(low/cheap,high/expensive)?\n");
   scanf("%s",concrete);
   printf("How many cubic yards of concrete?\n");
   scanf("%d",&yard);/*Reading input from the user*/
   if(strcmp("low",concrete)==0||strcmp("cheap",concrete)==0)
   { /*If low or chep*/
       if(yard<200)
       {/*If yard less than 200 we multiply yard*100*/
           printf("The cost is $%d",yard*100);  
       }
       else if(yard<=400)
       {/*If yard less than or equals 400 we multiply yard*95*/
           printf("The cost is $%d",yard*95);  
       }  
       else if(yard>400)
       {/*If yard greater than 400 we multiply yard*95*/
           printf("The cost is $%d",yard*90);
       }
   }
   else if(strcmp("high",concrete)==0||strcmp("expensive",concrete)==0)
   {/*IF high or expensive*/
       if(yard<250)
       {/*If yard less than 250 we multiply yard*150*/
           printf("The cost is $%d",yard*150);      
       }
       else
       {/*If yard grater or equals to 250 we multiply yard*135*/
           printf("The cost is $%d",yard*135);  
       }
   }
}

output:

Indentation:


Related Solutions

You isolated a new species of bacteria from your backyard and want to gain insight into...
You isolated a new species of bacteria from your backyard and want to gain insight into its fundamental vs. realized niche. What would you do? You have access to any and all resource/technology/method.
(LANGUAGE C++) This time, you will finish the program so that the user gets to solve...
(LANGUAGE C++) This time, you will finish the program so that the user gets to solve the puzzle. You will also use header files and introduce classes into your program. We will follow the draft start to how to incorporate classes. Here are the requirements: ·In the file quotes.h, define the Quotes class: o   Quotes(string filename) // a constructor to load quotes from the named file into a vector o   The vector should be a field of the class so it will...
It is your 25th birthday (end of 25 years) and you decide that you want to...
It is your 25th birthday (end of 25 years) and you decide that you want to retire on your 65th birthday (end of 65 years - 40 years later). Your salary is $55,000 per year and you expect your salary to increase by 3% each year for the next 40 years. When you retire, you want your retirement fund to provide an annual payment equal to 80% of your salary at age 65 and to increase by 2% a year...
You are looking at a new project and need to decide if your company will want...
You are looking at a new project and need to decide if your company will want to go through with this investment. Initial Investment = -150,000 CF year 1             =    65,000 CF year 2             =    45,000 CF year 3             =    60,000         CF year 4             =    55,000 The rate of return on this investment is 11%. What is the IRR & Payback
You decide you want your child to be a millionaire. You have a daughter today and...
You decide you want your child to be a millionaire. You have a daughter today and you deposit $59,000 in an investment account that earns 7.5% per year. The money in the account will be distributed to your daughter whenever the total reaches $3,750,000. How old will your daughter be when she gets the money (rounded to the nearest year)? Please show work
How to make this problem? in C language Build an algorithm that, upon receiving as input...
How to make this problem? in C language Build an algorithm that, upon receiving as input the ID and salary of the professors of a university, determines the following: -Total payroll of teachers. -The average salaries of teachers. -ID of the employee with the highest salary as well as what's his salary thanks
1. While watching a storm, you decide to use your audio an electronic skills to build...
1. While watching a storm, you decide to use your audio an electronic skills to build an apparatus to measure the distance from a lightning strike using a light detector and a microphone. When the light detector picks up a lightning flash, the apparatus then measures the time until the microphone picks up the thunder. On your first trial with this apparatus, it seems to work! It measures a time of 6.93 second between the lightning and thunder. Take the...
You decide to save for your dream vacation to Europe (London,Paris, and Rome). You want...
You decide to save for your dream vacation to Europe (London, Paris, and Rome). You want to be able to travel in 10 years. If you believe your trip will cost $5,514 and you can earn 5.2 percent annual interest on your savings, how much must you deposit today so you can afford your trip in 10 years?  DO NOT USE DOLLAR SIGNS OR COMMAS IN YOUR ANSWER. ROUND ANSWER TO THE NEAREST DOLLAR.
Fresh off the excitement of the 2012 London Olympic Games, you decide that you want your...
Fresh off the excitement of the 2012 London Olympic Games, you decide that you want your firm to take advantage of the profits to be made for the 2016 games in Rio de Janeiro. To do so you plan to open a factory in Brazil. After examining the idea, your CFO projects revenues next year (2013) to be $15 million and costs to be $7 million. Both of these are expected to grow at a rate of 22.0% per year...
  YOU WANT TO PROTECT YOUR INVESTMENT SO YOU BOUGHT A SROCK AT 100 AND THE STRIKE...
  YOU WANT TO PROTECT YOUR INVESTMENT SO YOU BOUGHT A SROCK AT 100 AND THE STRIKE PRICE IS 100 DOLLAR YOU PAID 3 DOLLARS AS PREMIUM SHOW THE MAX LOSS MAX PROFIT, BREAK EVEN If price is now 95 what is your profit? AND PLOTT IT ON A DIAGRAM
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT