1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
user100 [1]
3 years ago
7

Write a C function (NOT A COMPLETE PROGRAM) which uses the RETURNstatement to calculate and return the total cost for purchasing

books (quantity * bookcost). The parameter needed is the quantity of books wanted. If 20 or fewer books are wanted, then each book costs $23.45. If 21 to 100 books are wanted, then each book costs $21.11. If more than 100 books arewanted, then each book costs $18.75. Please assume that number of books passed to your function is positive.
Computers and Technology
1 answer:
stira [4]3 years ago
3 0

Answer:

int calculate_cost(int quantity) {

   double cost = 0;

   if (quantity <= 20)

       cost = quantity * 23.45;

   else if (quantity >= 21 && quantity <= 100)

       cost = quantity * 21.11;

   else if (quantity > 100)

       cost = quantity * 18.75;

   

   return cost;

}

Explanation:

Create a function called calculate_cost that takes one parameter, quantity

Initialize the cost as 0

Check the quantity using if else structure. Depending on the quantity passed, calculate the cost. For example, if the quantity is 10, the cost will be $234.5

Return the cost

You might be interested in
Which are factors that go into a project plan?
BaLLatris [955]

Answer:

The four critical factors to planning a successful project

Explanation:

5 0
3 years ago
Which pickaxe in minecraft to use?
Law Incorporation [45]

Answer:

Diamond pickaxe with efficiency 3

Explanation: It will mine quicker and you can just get unbreaking

6 0
2 years ago
The domain in an email message tells you the
Alexus [3.1K]
The type of service provider
8 0
3 years ago
How does Programming change with the times?
KonstantinChe [14]

Answer:

by coding

Explanation:

4 0
2 years ago
Why must an rodc be able to connect to at least one windows server 2008 or higher domain controller?
raketka [301]
<span>Ensure that at </span>least one<span> writable </span>DC<span> must be running </span>Windows Server 2008<span> or higher before you can deploy a Read-Only-Domain-Controller.</span>
6 0
3 years ago
Other questions:
  • Which is the last step in conducting a URL search?
    14·1 answer
  • In Word, tables can be styled much like text can.<br> True<br> False
    6·1 answer
  • Why isn't my rank move from ambitious to virsto i met all the requirements
    8·2 answers
  • Which best explains what a credit score represents
    10·2 answers
  • What is the difference between primary storage,secondary storage and offline storage what type of storage can be
    6·2 answers
  • Can a computer will work more efficiently if you perform disk optimization
    9·1 answer
  • A​ _______ helps us understand the nature of the distribution of a data set.
    10·1 answer
  • A business traveler notices there is an extra connector between the keyboard and the computer, in a business center. She has mos
    12·1 answer
  • Write a java program that prompts the user to input the elapsed time for an event in hours, minutes, and seconds. The program th
    13·1 answer
  • Classify the functions of dhcp and dns protocols​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!