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
There is a feature that allows you to lock the document, to avoid others making changes. True or False
Burka [1]

Answer:

yes there is

Explanation:

6 0
3 years ago
Is the process of modifying something to make it fit certain criteria.
alexandr402 [8]

Answer:

Design Process

8 0
2 years ago
Linda wants to change the color of the SmartArt that she has used in her spreadsheet. To do so, she clicks on the shape in the S
Julli [10]

Answer: Theme colors

Explanation:

Based on the directions, Linda most probably went to the "Theme colors" option as shown in the attachment below. Theme colors enables one to change the color of their smart shape.

It is located in the "Format tab" which is under "Drawing tools" in the more recent Excel versions. Under the format tab it is located in the Shape Styles group as shown below.

8 0
2 years ago
Maxwell says three things Level Two Leaders do well are:
IRINA_888 [86]

Answer:

true

Explanation:

3 0
3 years ago
Hi, please help me, solution.​
loris [4]

Answer:

error: incompatible types

Explanation:

Given

The attached code

Required

The output

Variable "a" is declared as float

While p is declared as a pointer to an integer variable

An error of incompatible types will be returned on line 3, <em>int *p = a;</em>

Because the variables are not the same.

To assign a to p*, we have to use type casting.

Hence, (b) is correct

5 0
3 years ago
Other questions:
  • What can a folder on a computer contain?
    13·2 answers
  • Difference between implicit and explicit type casting
    7·2 answers
  • Write a function called printbackwards() that will work with a c++ string
    14·1 answer
  • Entering the formula =SUM(C5:C18) in cell C19 will result in which of the following?
    10·1 answer
  • Hi I am Khine Mye and I want to ask you a question I don't know that is square root of 2 is 1.4 and how to get that 1.4 and plz
    8·1 answer
  • What kind of security features does Microsoft Security Analyzer promise?
    5·1 answer
  • What is a well-planned strategy that ensures the search and navigation functions are easy to use and user-friendly on a website?
    15·1 answer
  • List at least 5 features that can be used to format a report in word 2013
    6·1 answer
  • Why does the media play such an important role in our personal freedom? Select 3 options.
    6·1 answer
  • The users, groups, and roles that have access to a server are called ______________________________.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!