Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

8.11 Lab 8C: Clothing Store Transaction Overview Write a program that outputs the cost of a transaction given the number of clothing items, using your

8.11 Lab 8C: Clothing Store Transaction

Overview

Write a program that outputs the cost of a transaction given the number of clothing items, using your own functions.

Objectives

  • To be able to write a user defined function with a parameter and a return value
  • To get experience calling a function with an argument that is dependent on user input
  • To get experience using the return value of the function

Description

A clothing store is running a sale and needs a program that will calculate the total purchase price of a transaction given the number of shirts, pairs of pants, and hats purchased in the transaction. The regular prices of these items is as follows:

  • Shirt: $10.00
  • Pants: $20.00
  • Hats: $5.00

For this sale, shirts are 20% off, and hats are buy-one-get-one free. Pants are still full price. Write three functions that compute and return the total cost of a given number of a specific clothing items, given the current sale. The three functions must be named as follows:

  • cost_shirts(num_shirts)
  • cost_pants(num_pants)
  • cost_hats(num_hats)

For example, the function call cost_shirts(5) must return the final cost of 5 shirts, taking into account the shirt price and the sale.

Your main code must ask the user for three inputs using the following prompts. Note that there is a space at the end of each prompt.

Enter the number of shirts: Enter the number of pants: Enter the number of hats: 

After obtaining the inputs, call your functions appropriately, and use the return values to compute the total price of the purchase. Output the purchase price in this pattern: The final price of X shirts, X pants, and X hats is $X. Where the X's are the number of shirts, number of pants, number of hats, and total purchase price. Note: the total purchase price must be output with exactly two decimal places.

Example run of the program:

Enter the number of shirts: 1 Enter the number of pants: 1 Enter the number of hats: 3 The final price of 1 shirts, 1 pants, and 3 hats is $38.00.

Default template:

# Define your functions here

if __name__ == '__main__': # Type your code here. Your code must call the calculate_total_cost() function. # Notice the indentation level

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

Step: 3

blur-text-image

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

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago