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
PLEASE HELP THIS WAS DUE YESTERDAY AND I DIDN'T GET TO IT IN TIME!!!!!!
kykrilka [37]

Answer:

dDAgv

Explanation:

sdc sdc sdc trust me

7 0
2 years ago
What is SEO and SEM?
velikii [3]

Answer:

SEO stands for “search engine optimization.” In simple terms, it means the process of improving your site to increase its visibility for relevant searches.

SEM, or search engine marketing, is the act of using paid strategies to increase search visibility.

4 0
2 years ago
The following program segment is designed to compute the product of two nonnegative integers X and Y by accumulating the sum of
mote1985 [20]

The program is correct: at the beginning, product = 0. Then, we start summing Y to that variable, and we sum Y exactly X times, because with each iteration we increase Count by 1, and check if Count=X so that we can exit the loop.

5 0
3 years ago
Which is a safe Internet behavior?
Westkost [7]
Don’t give out personal information
7 0
3 years ago
Computer identity theft differs from theft in the real world in what major way?
CaHeK987 [17]

Answer:

The answer is B

5 0
2 years ago
Read 2 more answers
Other questions:
  • Consider the following class definitions. public class BClass { private int x; public void set(int a) { x = a; } public void pri
    11·1 answer
  • What advantage do ExpressCard modules and U.S.B adapters offer over expansion cards?
    10·1 answer
  • The procedure call mystery(38) will yield which output? __________ a) 0 12 b) 12 0 c) 1 1 0 2 d) 1 1 1 1 e) 2 0 1 1 public void
    11·1 answer
  • The calls radioed to patrol officers, or assignments given to police patrol units by 911 dispatchers, reveal the types of proble
    9·1 answer
  • How often does colleges update the cost of attendance on their website?.
    13·1 answer
  • How might the website owner use theses details other than to verify login details?
    6·2 answers
  • What is the definition of a digital signal?
    14·1 answer
  • Guess The Song: <br> What Popping Brand New Whip Just Hopped In, I Got options
    15·1 answer
  • What is the range for copper tape
    15·1 answer
  • You are planning to write a guessing game program where the user will guess an integer between one and 20. Put the commented ste
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!