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
lidiya [134]
3 years ago
12

Write a C function which takes three parameters which are the cost for an item in a grocery store, the quantity to buy, and the

tax percentage. The function should calculate and return the following values:
The cost before the tax amount(cost*quantity)
The tax amount(the cost before the tax amount* tax%/100
The cost with the tax amount( the cost before the tax amount+ the tax amount) for the item
(NOT A COMPLETE PROGRAM)
Computers and Technology
2 answers:
Fittoniya [83]3 years ago
5 0

Answer:

#include<cstdio>

#include<conio.h>

using namespace std;

float groceryamount(float cost, int quantity, float taxrate, float *costbefortax, float *taxamount, float *costaftertax);

int main()

{

float cost, taxrate, costbefortax, taxamount, costaftertax,a,b,c;

int quantity;

printf("enter the cost of product");

scanf("%f",&cost);

printf("enter the quantity of product that required");

scanf("%d",&quantity);

printf("enter the tax rate in percentage");

scanf("%f",&taxrate);

groceryamount(cost, quantity, taxrate, &costbefortax, &taxamount, &costaftertax);

printf("\nTotal amount before tax = %f", costbefortax );

printf("\n Total Tax Amount =  %f", taxamount );

printf("\n Total Amount After Tax Deduction = %f", costaftertax );

getch();

}

float groceryamount(float cost, int quantity, float taxrate, float *costbefortax, float *taxamount, float *costaftertax)

{

float a,b,c;

a= cost * quantity;

b=  a * (taxrate/100);

c= a - b;

*costbefortax=a;

*taxamount=b;

*costaftertax=c;

}

Explanation:

The program has six variable that have different data types. Therefore the function data type is void. I use cost, taxrate, costbefortax, taxamount and costaftertax in float as all these values could be in decimal. The quantity is usually in integer so I take it as int data type. cost before tax, tax amount and cost after tax has been calculated using function and returned to the main function.

xeze [42]3 years ago
4 0

Answer:

struct item

{

  float previousCost;

  float taxAmount;

  float updatedCost;

} itemObject;

void calculation(int cost,int quantity,float tax)

  {

      struct item *itemPointer=&itemObject;

      itemPointer->previousCost=(cost) * (quantity);

      itemPointer->taxAmount=itemPointer->previousCost * (tax/100);

      itemPointer->updatedCost=itemPointer->previousCost+itemPointer->taxAmount;

  }

Explanation:

  • Define a structure called item that has 3 properties namely previousCost, taxAmount and updatedCost.
  • The calculation function takes in 3 parameters and inside the calculation function, make a pointer object of the item structure.
  • Calculate the previous cost by multiplying cost with quantity.
  • Calculate the tax amount by multiplying previous cost with (tax / 100).
  • Calculate the previous cost by adding previous cost with tax amount.
You might be interested in
On January 1, 1980, Moises deposited $1850 into a savings account paying 5.6% interest, compounded quarterly. If he hasn't made
kondaur [170]
The rule of 72 says that if you divide 72 by the interest rate the result is the number of years it takes to double your money.

72/5.6 = 12.86 years. to double your money from $1850 to $3700 it would take 12.86 years, which means you will have $3700 near the end of 1992.
8 0
3 years ago
Read 2 more answers
A cover letter should simply restate what is included in your résumé.<br> True<br> False
stich3 [128]
True because all resumes need a cover letter

6 0
3 years ago
Read 2 more answers
If you wanted to look up an article from the Chicago Tribune the best place to start would be
anyanavicka [17]
Books,well trusted websites , news.reports , schools library (online and off ) hope this helps.:-)
7 0
3 years ago
Which page format would you likely use for a photograph of a standing tree? AND why would you use that format?
VladimirAG [237]
Portrait since it is more tall then wide
4 0
3 years ago
For questions 3-6, consider the following two-dimensional array:
elena-s [515]

Answer:

5= Fabric

6=bandana

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • The left column values in a table array are called table ____
    13·1 answer
  • You are an administrator for contoso.com. you have two servers called server1 and server2 that run windows server 2012 and have
    9·1 answer
  • ‘Bottom of the pyramid’ innovation refers to ancient Egyptian approaches to new product development – true or false?
    8·1 answer
  • As an administrator for the Contoso Corporation, your primary office is in Sacramento and your data recovery site in Las Vegas.
    15·1 answer
  • To create a cover letter to send to potential employers along with a resume, what software program should you use ?
    6·2 answers
  • TWO MINUTES LEFT<br> ________ __________ is the physical arrangement of devices on a network.
    9·1 answer
  • Assume that strikeCounter has already been declared to be a "pointer to int". Assume further that strikeCounter has been initial
    7·1 answer
  • Which These operating systems use a graphical user interface?
    6·1 answer
  • Please what do you guys think about this ?
    10·2 answers
  • b. Write a complete program for the following situation related to setting the speed of a car to preset values before starting a
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!