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
When keying, keep fingers curved and upright over the home keys.<br> False<br> True
Dmitry [639]

Answer:

This is true.

Explanation:

I think everyone was taught to to type correctly sometime in school or at home. It helps you proficiently type. But most people don't use the Home Room Key Technique. Most use the "Chicken peck"

3 0
3 years ago
What is 1 of the rules for naming variables?
vova2212 [387]

Answer:

<h3>Rules for Naming Variables</h3><h3>The first character must be a letter or an underscore (_). You can't use a number as the first character. The rest of the variable name can include any letter, any number, or the underscore. You can't use any other characters, including spaces, symbols, and punctuation marks.</h3>

<em><u>#</u></em><em><u>M</u></em><em><u>a</u></em><em><u>r</u></em><em><u>k</u></em><em><u>a</u></em><em><u>s</u></em><em><u>b</u></em><em><u>r</u></em><em><u>a</u></em><em><u>i</u></em><em><u>n</u></em><em><u>l</u></em><em><u>e</u></em><em><u>s</u></em><em><u>s</u></em><em><u>p</u></em><em><u>l</u></em><em><u>e</u></em><em><u>a</u></em><em><u>s</u></em><em><u>e</u></em><em><u>✅</u></em>

3 0
2 years ago
How many lines are on a standard sheet of typing paper?
kotegsom [21]
60 lines on the paper
3 0
3 years ago
In your opinion, why did Proponents<br>of IPs used IPV6 instead of IPv5​
frutty [35]

Answer:

The following where many reasons why IPv6 was used instead of IPv5 which are the limitation of it's 32 bit address, IPv5 began or used with a different name called Internet streaming, IPv6 provides unlimited addressing, because it comprises of 128 bit.

Explanation:

Solution:

The following reasons why Proponents  of IPs used IPV6 instead of IPv5​ is stated as follows:

  • Due to its limited 32 bit addressing
  • IPv6 offers almost unlimited addressing because of its 128-bit addressing
  • IPv5 started under a different name which is internet stream(ST)
  • ST(Internet streaming) was developed for streaming video and voice
  • ST was developed by Apple, NeXT, and Sun Microsystems
  • ST was effective on specific frequency to carry out communication
5 0
2 years ago
Double[][] vals = {{1.1, 1.3, 1.5},
Elis [28]

Answer:

Option 3 i.e., 7.3 is the correct answer to the following question.

Explanation:

In the following two dimensional array that is the double data type 2-D array variable "val" and it contains some float type information in the form of matrix that has 4 rows and 3 columns, In the following statement, they asked the value of 4th row and 2nd column and in the matrix 4th row and 2nd column contain the value i.e., 7.3.

3 0
3 years ago
Other questions:
  • Which step of creating a financial budget involves listing the payroll, rental, and utility costs?
    10·2 answers
  • Which wireless device does the manager most likely have before being offered the upgrade by her supervisor?
    8·2 answers
  • What are the different components of the cloud architecture?
    5·2 answers
  • A(n) ____ path is a path used for external links that includes the complete address for the destination page, including the prot
    12·1 answer
  • You're an administrator for a large corporation and you are responsible for deploying computers often and quickly. What server d
    10·1 answer
  • If all the data in a database is not physically located in one place, it would be a(n _______ database.
    5·1 answer
  • You are now going to prepare some reports for the company. Measurements are in metres and volume
    7·1 answer
  • k-means clustering cannot be used to perform hierarchical clustering as it requires k (number of clusters) as an input parameter
    15·1 answer
  • How to make your nest learning thermostat stop doing something
    14·1 answer
  • If you wish to install a new OS without disturbing the old one so that you can boot to either OS, what type of boot setup should
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!