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
PSYCHO15rus [73]
3 years ago
5

Write a program named as calcPrice.c that formats product information entered by the user and calculate the total amount of purc

hase.

Computers and Technology
1 answer:
Colt1911 [192]3 years ago
4 0

Answer:

Here is the calcPrice.c program:

#include <stdio.h>   //to use input output functions

int main(void)  {  //start of main method

   int itemNo, month, day, year, quantity;  //declares variables to hold item number, quantity, and date

   float unitPrice; //declare variable to hold price per unit

   printf("Enter item number: ");  // prompts user to enter item number

   scanf("%d", &itemNo);  //reads item number from user and stores it in itemNo variable

   printf("Enter unit price: ");  // prompts user to enter unit price

   scanf("%f", &unitPrice);  //reads input unit price and stores it in unitPrice variable

   

    printf("Enter quantity: ");  //prompts user to enter quantity

   scanf("%d", &quantity);  //reads input quantity and stores it in quantity variable

   printf("Enter purchase date (mm/dd/yyyy): ");  //prompts user to enter purchase date

   scanf("%d/%d/%d", &month, &day, &year);  //reads input date and stores it in month, day and year variables

    float totalAmount = unitPrice * quantity;  //computes the total amount

   printf("\nItem\tUnit Price\tQTY\tPurchase Date\tTotal Amount\n");  //displays the item, unit price, qty, purchase data and total amount with tab space between each

   printf("%d\t$%5.2f\t%d\t%.2d/%.2d/%d\t$%5.2f\n", itemNo, unitPrice,quantity, month, day, year,totalAmount);   }    //displays the values of itemNo, unitPrice, quantity, month, day, year and computed totalAmount with tab space between each

Explanation:

Lets suppose user enters 583 as item number, 13.5 as unit price, 2 as quantity and 09/15/2016 as date so

itemNo = 583

unitPrice = 13.5

quantity = 2

month = 09

day = 15

year = 2016

totalAmount is computed as:

  totalAmount = unitPrice * quantity;

 totalAmount = 13.5* 2

totalAmount = 27.00

Hence the output of the entire program is:

Item    Unit Price      QTY     Purchase Date   Total Amount      

583     $  13.50           2           09/15/2016         $  27.00  

The screenshot of the program along with its output is attached.

You might be interested in
The function known as "Comments" can be displayed during a presentation<br>O True<br>False​
Sonja [21]

Answer:

false

Explanation:

Select the comment icon. on the slide. The Comments pane will open and you can see comments for that slide.

Select Reply to respond to a comment.

Select the Next or Back buttons to go between comments and slides.

3 0
3 years ago
Read 2 more answers
Why do we install doorbells in our house
Vinil7 [7]

Explanation:

It's placed near the door. When a visitor presses the button, the bell rings inside alerting you that someone is at the door.

6 0
3 years ago
Read 2 more answers
What is the term for an e-mail server program that receives sent messages and delivers them to their proper destination?
Katarina [22]
MTA (Mail Transfer Agent)
6 0
3 years ago
Which of the following sentences is written in the active voice
STALIN [3.7K]
D. The chocolate cake will be served to the queen. This is the only one not in past tense. Active means present or near present, hence the word "will." 
3 0
3 years ago
Read 2 more answers
Please help me very important
3241004551 [841]

Answer:

C, Or D.

Explanation:

<em>Because A speed enhancing hard drive Can store any type of quick file if you just click on it will load fast. Same thing goes for a hard drive but you have to transfer the file</em>

4 0
3 years ago
Other questions:
  • Which of the following is an unintended consequence of pesticide use on crops?
    10·1 answer
  • A) A cable that is mainly used in the cable television network
    11·1 answer
  • Technician A says that S-cams can be left or right handed. Technician B says that S-cam foundation brakes can have one or two an
    15·1 answer
  • What is the smartest person ever
    15·2 answers
  • Let x = ["Red", 2.55,"Green", 3,"Black","false"], then solve the following:
    7·1 answer
  • Greg wants to check the amount of requests his website receives. What test can he use?
    6·1 answer
  • c) If you are at foreign country visit, which banking card would you prefer to keep with you during visit (Debit Card or Credit
    10·1 answer
  • Three types of query​
    13·1 answer
  • __________ implements a security policy that specifies who or what may have access to each specific system resource and the type
    8·1 answer
  • Compare the freedom available to the American media with the freedom available to media in other parts of the world. How does a
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!