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.
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 trying to decide on the best mode of transportation for your company. You want...
You are trying to decide on the best mode of transportation for your company. You want to balance the cost of faster transportation with holding more inventory. This is because the amount of inventory you must hold is a function of lead time. It costs $15 per unit per year to hold a product in inventory. The forecasted demand for this product is 10,000 units per year. The total amount of inventory is made up of two types of inventory:...
You are trying to decide on the best mode of transportation for your company. You want...
You are trying to decide on the best mode of transportation for your company. You want to balance the cost of faster transportation with holding more inventory. This is because the amount of inventory you must hold is a function of lead time. It costs $15 per unit per year to hold a product in inventory. The forecasted demand for this product is 10,000 units per year. The total amount of inventory is made up of two types of inventory:...
(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...
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
write code data structure using  c language You will build a system to manage patients’ data in...
write code data structure using  c language You will build a system to manage patients’ data in a hospital. The hospital patient management system stores specific information in the form of health record to keep track of the patients’ data. Your program should read the information from a file called “patients.txt” that should be on the following format : Patient Name#Gender#Date of admission#Date of birth #Illness#Address (City)#Blood type Your program should be able to do the following tasks: Options: 1. Read...
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...
I want c++ /c program to build a double linked list and find with a function...
I want c++ /c program to build a double linked list and find with a function the middle element and its position and the linked list must be inserted by the user aand note You should handle the both cases of whether the size of the list even or odd
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT