Assume that an imaginary supermarket sells items that are identified by a unique item number which is an integer in range 100 to 499 inclusive. The items are classified in four different categories based on their numbers, and each category defines a different sales tax rate. These four categories along with the range of item numbers included in them, and their specific sales tax rates has been summarized in the following table:
Category Item Numbers Sales Tax Rate
A 100 - 199 0
B 200 - 299 5%
C 300 - 399 7%
D 400
-
499 12%
You are to write a program that reads the number and the price of
an item from the keyboard and displays the applicable tax rate and
the price after tax on the screen.
a) Identify the inputs and the outputs of this program along with
their data types. [10 marks]
b) Use structured English, as explained in the class, to write an algorithm for this problem. [20 marks]
c) Write a Python program for your algorithm in a function named
main1(). [20 marks]
Question 2 [50 marks]
Based on the information provided in Question 1, write an algorithm
for a program that reads the information of the items sold to a
customer from the keyboard and displays the invoice including the
total before tax, total tax, and total plus tax on the screen.
Format your output as shown in the following
example: Total Before
Tax Total
Tax Total
Plus Tax
1000.00
125.00
1125.00
NOTES: 1. The shopped items’ information is entered by the user one at a time and includes the item number, the item price, and the quantity. 2. Format your output to be printed organized like a table. To do so, try to set up an appropriate minimum field width, change the alignment of your outputs, and consider two digits of precision for your amounts. 3. Validate your inputs when necessary and display an error message in case an error happens. 4. Write your code in a function named main2() and add it to the Python file you created for Question 1.
part1
""" a) Identify the inputs and the outputs of this program along with their data types. [10 marks] INPUTS item number : int item_price : float OUTPUTS tax: float total price: float b) Use structured English, as explained in the class, to write an algorithm for this problem. [20 marks] get the item_num from user get the item_price from user find the tax rate from given category used the if elif condition for finding the appropriate tax rate once tax rate found calculate the tax by formula (item_price * tax_rate)/100 add the tax to price for final price out put the tax and total price """
def main1(): item_num = int(input("Enter item number: ")) item_price = float(input("Enter price: ")) tax_rate = 0 if 100 <= item_num <= 199: tax_rate = 0 elif 200 <= item_num <= 299: tax_rate = 5 elif 300 <= item_num <= 399: tax_rate = 7 elif 400 <= item_num <= 499: tax_rate = 12 tax = ((item_price * tax_rate) / 100.0) total_price = item_price + tax print("Applicable tax: {0}".format(tax)) print("Item Price with tax: {0}".format(total_price))
part 2
def main2(): while 1: item_num = input("Enter item number: ") if not item_num.isnumeric(): print("invalid number format, enter numeric digit only! try again") continue item_num = int(item_num) if not 100 <= item_num <= 499: print("invalid number! valid only [100-499]") continue break while 1: try: item_price = float(input("Enter price: ")) break except: print("invalid price! try again") while 1: quantity = input("Enter Quantity: ") if not quantity.isnumeric() or int(quantity) < 1: print("invalid quantity! try again.") else: break quantity = int(quantity) if 100 <= item_num <= 199: tax_rate = 0 elif 200 <= item_num <= 299: tax_rate = 5 elif 300 <= item_num <= 399: tax_rate = 7 elif 400 <= item_num <= 499: tax_rate = 12 item_price = item_price * quantity tax = ((item_price * tax_rate) / 100.0) total_price = item_price + tax print("{:20}{:15}{:15}".format("Total Before Tax", "Total Tax", "Total Plus Tax")) print("{:.2f}{:-20.2f}{:-15.2f}".format(item_price, tax, total_price))
# OUT
please do let me know if u have any concern...
Assume that an imaginary supermarket sells items that are identified by a unique item number which...
PYTHON Programming Exercise 2: Create a Simple Cost Calculator Write a program that displays input fields (item name and cost) and calculates and displays the calculated costs. The program should do the following: Provide data entry areas for item name and cost. Calculate and display the subtotal of all items. Adds a sales tax of 6% and calculate and displays the total cost. Enter the following values into your program. Mother Board $200. RAM $75. Hard Drive $72. Video Graphics...
:) Problem: ??? Your task: implement in CH the algorithm solution shown below. Then analyze it and explain, using just one or two sentences, what it does. Write this explanation as a comment at the top of your program. This explanation will be worth 5 points of your total grade. Do not be too detailed (for example, do not write it opens a file and then declares variables, and then reads from a file...), it should look like the problem...
Assume that you are developing a billing software for a departmental store which sells electronic appliances, clothing, and toys. The store offers discounts on a festival occasion as below: a) 20 % discount on electronic appliances whose prices are greater than or equal to $100 b) 30 % discount on clothing if the price of a clothing item is greater than or equal to $50 c) All the toys greater than or equal to $20 are subject to 10% discount....
) Al Shams supermarket is a largest shopping center in Oman for electronic items and home appliance. They want to create invoice for their customer after they supplying the goods. Write a Python program to ask the user to input the purchase amount, customer type ('O': Online or 'F': Offline) for 10 customers and store them in two different lists. The sample input data is shown below. [15 Marks) Purchase Amount=(100, 75, 110,300,150, 400, 200, 100, 140, 100] Customer Type...
in java PART ONE ======================================= Below is the "RetailItem" class definition that we used in Chapter 6. Write a "CashRegister" class that leverages this "RetailItem" class which simulates the sale of a retail item. It should have a constructor that accepts a "RetailItem" object as an argument. The constructor should also accept an integer that represents the quantity of items being purchased. Your class should have these methods: getSubtotal: returns the subtotal of the sale, which is quantity times price....
In c++ Section 1. Stack ADT – Overview Data Items The data items in a stack are of generic DataType. This means use should use templating and your Node class. Structure The stack data items are linearly ordered from the most recently added (the top) to the least recently added (the bottom). This is a LIFO scheme. Data items are inserted onto (pushed) and removed from (popped) the top of the stack. Operations Constructor. Creates an empty stack. Copy constructor....
Please help me to do my assignment it should be python. Thank you Write a menu-driven program for Food Court. (You need to use functions!) Display the food menu to a user (Just show the 5 options' names and prices - No need to show the Combos or the details!) Ask the user what he/she wants and how many of it. (Check the user inputs) AND Use strip() function to strip your inputs. Keep asking the user until he/she chooses...
Question III This question carries 20% of the marks for this assignment. Given the following mix of tasks, task lengths and arrival times, compute the completion [5 marks and response time time from the arrival to the finish time) (5 marks for each task, along with the average response time for the FIFO. RR and SJF algorithms. Assume a time slice of 10 milliseconds and that all times are in milliseconds. You are kindly asked to provide the Gantt Chart...
Python Problem, just need some guidance with the description, pseudocode and run time. I believe this is an 0-1 knapsack problem? Shopping Spree: (20 points) Acme Super Store is having a contest to give away shopping sprees to lucky families. If a family wins a shopping spree each person in the family can take any items in the store that he or she can carry out, however each person can only take one of each type of item. For example,...
PYTHON 3 Object Oriented Programming ***a9q3.py file below*** class GradeItem(object): # A Grade Item is anything a course uses in a grading scheme, # like a test or an assignment. It has a score, which is assessed by # an instructor, and a maximum value, set by the instructor, and a weight, # which defines how much the item counts towards a final grade. def __init__(self, weight, scored=None, out_of=None): """ Purpose: Initialize the GradeItem object. Preconditions: :param weight: the weight...