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
2-Write test programs in java to determine the scope of a variable declared in a for statement. Specifically, the code must dete
ankoles [38]

Answer:

See Explaination

Explanation:

public class testscope

{

//start of main function

public static void main(String[] args)

{

//varible declration

int i;

int x;

//loop for 10 times

for(i=0; i<10; i++)

{

//initialize value of x to 10

x = 10;

}

//the scope of variable x is visible outside of for loop

System.out.println("The value of x is: "+x);

}

}

See attachment for sample output

nb:

You can clearly see in the output of Java program the value of x is not printed and program return errors. It means the variable x declared inside for loop does not has scope outside the for loop.

7 0
3 years ago
Which of the following is an example of tangible property?
lyudmila [28]
<span>B an idea for an invention that your dad mentioned briefly but did not write down</span>
8 0
3 years ago
Describe a situation in which you have experienced harm as a consequence of a failure of computer security. Was the failure mali
frutty [35]

Answer: The goals of computer security are to protect computers and users from data theft or loss as well as damage to any part of the computer.

Explanation: Common means of achieving computer security are firewalls, anti-virus software and this can fail due to hardware problems  or   weaknesses that prevent malicious attacks.

To answer this question, think of a time when you experienced any one of these. For example, personally, I was once an unfortunate victim of a general malicious attack that took advantage of a weakness in my anti-virus software. After clicking on a link on a dodgy website, a virus was installed on my computer. My computer finally crashed, without any hope of restarting it. I lost all my data and I had to buy a new computer.  This was a malicious attack.

However, sometimes people can be specifically targeted to steal their data or monitor their activities.  

7 0
3 years ago
In a C++ program, one and two are double variables and input values are 10.5 and 30.6. After the statement cin &gt;&gt; one &gt;
SSSSS [86.1K]

Answer:

variable one stores 10.5 and two stores 30.6

Explanation:

In c++ language, the cout keyword is used to write to the standard output. The input from the user is taken by using the cin keyword.

For the input from the user, a variable need is declared first.

datatype variable_name;

The input can be taken one at a time as shown.

cin >> variable_name;

The input for more than one variable can be taken in a single line as given by the syntax below.

1. First, two variables are declared.

datatype variable_name1, variable_name2;

2. Both input is taken simultaneously as shown.

cin >> variable_name1, variable_name2;

For the given scenario, two double variables are declared as below.

double one, two;

The question mentions input values for the two double variables as 10.5 and 30.6.

3. The given scenario takes both the values as input at the same time, in a single line as shown below.

cin >> one >> two;

4. After this statement, both the values entered by the user are accepted.

The values should be separated by space.

First value is stored in the variable one.

Second value is stored in the variable two.

5. The user enters the values as follows.

10.5 30.6

6. The value 10.5 is stored in variable one.

7. The value 30.6 is stored in variable two.

The c++ program to implement the above is given below.

#include <iostream>

using namespace std;

int main() {

   double one, two;      

   cout << " Enter two decimal values " << endl;

   cin >> one >> two;

   cout << " The input values are " << endl;

   cout << " one : " << one << " \t " << " two : " << two << endl;

   return 0;

}

OUTPUT

Enter two decimal values  

10.5 30.6

The input values are  

one : 10    two : 530.6

6 0
3 years ago
The Bradshaw family has $200,000 of total assets and $140,000 of liabilities. What is their net worth?
3241004551 [841]

Answer:

$340,000 is there net worth

Explanation:

$200,000+ $140,000 = $340,000

5 0
3 years ago
Other questions:
  • ou work as network administrator for an organization that has a Windows-based network. You want to use multiple security counter
    10·1 answer
  • Data arranged and stored in a data set
    9·1 answer
  • Given a double variable named areaofsquare write the necessary code to read in a value , the area of some square, into areaofsqu
    9·1 answer
  • What are three steps to use to research relevant information on the internet? (Site 1)
    13·2 answers
  • To build a user interface that contains graphical components, the components ____. must each be added to a separate panel. must
    7·1 answer
  • Which of the following is generally true about 401(k) and 403(b) retirement plans
    5·1 answer
  • Who can add entries to value log
    8·1 answer
  • What is the school wifi password trying to do my class work in school on different devices.
    9·1 answer
  • Rosanna is a middle school teacher. She has installed a spreadsheet program in her computer that tracks the grades and attendanc
    10·1 answer
  • eocs can be fixed locations, temporary facilities, or virtual structures with staff participating remotely.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!