Question

Please solve the following in Python 3 only. Also, share code and show output. A software...

Please solve the following in Python 3 only.

Also, share code and show output.

A software company sells a package that retails for $99. Quantity discounts are given according to the following table.

Quantity Discount
10–19 20%
20–49 30%
50–99 40%
100 or more 50%

Write a program that asks for the number of units sold and computes the total cost of the purchase.

Input Validation: Make sure the number of units is greater than 0.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

print("Enter the number of units sold: ")
# input the number of units sold
n=int(input())
total=0
# if n<0 then it is an invalid input
if n<0:
print("Invalid input!!")
else:
# calculate the total cost
total = n*99
# now subtract the discount from the total cost based on the given conditions
if n>=1 and n<=9:
total = total - 0
elif n>=10 and n<=19:
total = total - 0.2*total
elif n>=20 and n<=49:
total = total - 0.3*total
elif n>=50 and n<=99:
total = total - 0.4*total
else:
total = total - 0.5*total
print("The total cost of the purchase =",total)

Add a comment
Know the answer?
Add Answer to:
Please solve the following in Python 3 only. Also, share code and show output. A software...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Code in c++ please Q1: Software Sales A software company sells a package that retails for...

    Code in c++ please Q1: Software Sales A software company sells a package that retails for $99. Quantity discounts are given according to the following table: QuantityDiscount 10-19 20-49 50-99 100 or more 20% 30% 40% 50% : Write a program that asks for the number of units sold and computes the total cost of the purchase. Input validation: Make sure the number of units is greater than 0. Q2: Book Club Points Community Booksellers has a book club that...

  • Q4 130 Quantity discounts are given according to the following table O points) A software company...

    Q4 130 Quantity discounts are given according to the following table O points) A software company sells one software package regularly for 99 QR Quantity Discount 20% 10-19 20-49 50-99 |00 or more 40% 50% write ρ program that asks for the number of items sold, and computes the total cost of the purchase. if the user enters an invalid number of items, the program displays invalid Purchasel" message. Sample output Enter number of items: 25 Total cost is 1732.5...

  • Computer science help! A software company sells their software packages for $99.00 each. They would like...

    Computer science help! A software company sells their software packages for $99.00 each. They would like you to write a program that will calculate and display an invoice for their customers. Quantity discounts are given according to the following table: Quantity   Discount 1 - 9 No discount 10 – 19 20% 20 – 49 30% 50 - 99 40% 100 or more 50% Write a C++ program that asks for the customer’s name and the number of software packages sold...

  • Python Language 3. Shipping Charges The Fast Freight Shipping Company charges the following rates (per 500...

    Python Language 3. Shipping Charges The Fast Freight Shipping Company charges the following rates (per 500 miles shipped): 1. Number Guessing Game Write a program for players to guess the number that the program randomly generated. Your program should randomly generate an integer between 1 and 10. After a player guessing a number, your program should display "Too small", "Too large", or "That's it!". Weight of Package (in Kilograms) 2 kg or less Over 2 kg but not more than...

  • I'm having trouble figuring out the C++ code for the following assignment, keep getting errors. Help?...

    I'm having trouble figuring out the C++ code for the following assignment, keep getting errors. Help? Write a program that calculates a discount for buying certain quantities of coffee. Consider the following scenario: A coffee company sells a pound of coffee for $12.99. Quantity discounts are given according to the table below. Quantity Discount 5-9 5% 10-19 10% 20-29 15% 30 or more 20% Write a program that asks for the number of pounds purchased and computes the total cost...

  • Part II – Cost Calculator (15 Points) A software company sells a package that retails for...

    Part II – Cost Calculator (15 Points) A software company sells a package that retails for $ 99. Quantity discounts are given according to the following table: Quantity Discount 10 to 19 20% 20 to 49 30% 50 to 99 40% 100 or more 50% Write a program that asks the user to enter the number of packages purchased. The program should then display the discount percentage, amount of the discount (can be 0) and the total amount of the...

  • <Program 1: 50 points> software.cpp A software company sells a package that retails for $99. Quantity...

    <Program 1: 50 points> software.cpp A software company sells a package that retails for $99. Quantity discounts are given according to the following table. Quantity Discount 10-19 20% 20-49 30% 50-99 40% 100 or more 50% Write a program that asks for today's date (you MUST use cin >> date. Do not use getline(cin, date)), the company name and the quantity they wish to buy and computes the total cost of the purchase. If the user enters a negative value...

  • NOTE: All C++ programs that you write must have comments at the top with the program...

    NOTE: All C++ programs that you write must have comments at the top with the program name, your name, and the pseudocode describing what the program will do. 1. Create a new program that will calculate the total cost for software purchased from a store. Each software package costs $99.00, but discounts are given on the total cost, based on the number of packages purchased. a. Ask the user for the number of packages they want to buy b. Calculate...

  • 1. Please write the following code in Python 3. Also please show all output(s) and share...

    1. Please write the following code in Python 3. Also please show all output(s) and share your code. Below is a for loop that works. Underneath the for loop, rewrite the problem so that it does the same thing, but using a while loop instead of a for loop. Assign the accumulated total in the while loop code to the variable sum2. Once complete, sum2 should equal sum1. sum1 = 0 lst = [65, 78, 21, 33] for x in...

  • Solve only with python please and show a little bit of explanation thank you so i...

    Solve only with python please and show a little bit of explanation thank you so i can understand, i will thumbs up if correct :) Write a program that reads a series of numbers from standard input and prints a list containing those numbers. A sentinel value of -999 will indicate the end of the input values. Do not append the sentinel value onto the list. For example: Input Result 1 -999 Enter a number: 1 Enter a number: -999...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT