Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(about c language) Topics: C Fundamentals, Formatted Input/Output, Expressions, Selection Statements, Loops, Basic Types, Arrays, Functions Write a program (main) that gives a discount on

image text in transcribedimage text in transcribed (about c language) Topics: C Fundamentals, Formatted Input/Output, Expressions, Selection Statements, Loops, Basic Types, Arrays, Functions

Write a program (main) that gives a discount on products. Prompt the user to enter the product number. Prompt the user to enter either 1 (for amount) or 2 (for kilogram). Call get_price function. If the user enters 1 , prompt the user to enter the quantity of product. Call totalprice function. - Call discount function to make discount on the total price according to the amount of the product. o. If the user enters 2 , prompt the user to enter the kilogram of the product. Call totalPrice function. - No discount Display the total payment. The program has three functions: get_price, totalprice, and discount. Here are the prototypes for the three functions: float get_price(int productNo, int amountType); Returns the list price of the product. Suppose that product has the list price shown in the following table: float totalprice(float amount, float listPrice); Calculates the total price. float discount(float total_price, int amount); Returns the price after making the discount. Suppose that discount is shown in the following table: cted output(s): Enter the product number (1 for peach, 2 for pear, 3 for plum): 2 Enter 1 for amount, 2 for kilogram: 1 Enter the quantity: 1 The total is $0.99 Enter the product number ( 1 for peach, 2 for pear, 3 for plum): 2 Enter 1 for amount, 2 for kilogram: 2 How many kilograms: 5 The total is $24.95 Enter the product number (1 for peach, 2 for pear, 3 for plum): 2 Enter 1 for amount, 2 for kilogram: 1 Enter the quantity: 4 The total is $3.76 Enter the product number (1 for peach, 2 for pear, 3 for plum): 2 Enter 1 for amount, 2 for kilogram: 1 Enter the quantity: 7 The total is $6.24

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications Dexa 2022 Workshops 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 In Computer And Information Science 33

Authors: Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil ,Bernhard Moser ,Alfred Taudes ,Atif Mashkoor ,Johannes Sametinger ,Jorge Martinez-Gil ,Florian Sobieczky ,Lukas Fischer ,Rudolf Ramler ,Maqbool Khan ,Gerald Czech

1st Edition

3031143426, 978-3031143427

More Books

Students also viewed these Databases questions