This program is a simple shopping list

Assignment Help Programming Languages
Reference no: EM131200222

CP1404/CP5632 2016 SP2/22/52 Assignment 1 - Shopping List 1.0

Task:

You are to plan and then code a console-based program in Python 3, as described in the following information and sample output. This assignment will help you build skills using selection, repetition, file input/output, exceptions, lists/tuples, functions and string formatting. Do not to define any of your own classes. Assignment 2 will build on this program with more advanced code constructs including classes and a Graphical User Interface (GUI). Work incrementally on this task: complete small parts of it at a time rather than trying to get it all working at once.

 

Program Overview:

This program is a simple shopping list that could also be used for TODOs or similar purposes. The program maintains a list of items in a file, and each item has:

  • name, price, priority (1, 2 or 3), whether it is required or completed

Users can choose to see the list of required items or completed items, including a total of the (estimated) price of all of those items. The lists will be sorted by priority.

Users can add new items and mark items as completed.

They can't change items from completed to required.

 

Program Functionality Details:

Ensure that your program has the following features, as demonstrated in the sample output below.

Your program should:

  • display a welcome message with your name in it
  • display a menu for the user to choose from
  • return to the menu and loop until the user chooses to quit
  • error-check user inputs as demonstrated in the sample output
  • start by loading a CSV (Comma Separated Values) file of items that are in stock for hire;
    a sample CSV file is provided for you
  • (when the user chooses list) display a neatly formatted list of all the required items with their prices lined up and priorities
  • (when the user chooses show completed) display a similarly formatted list of completed items
  • (when the user chooses add) prompt for the item's name, price and priority, error-checking each of these, then add the item to the list in memory
  • (when the user chooses complete) display the same list of required items, then allow the user to choose one (error-checked), then change that item to completed
    • if no items are required, then a message should be displayed and the user returned to the menu
  • (when the user chooses quit) save the items to the CSV file, overwriting the file contents 

Coding Requirements and Suggestions:

  • Make use of named constants where appropriate.
  • Use functions appropriately for each significant part of the program: this is the divide-and-conquer problem-solving approach. Remember that functions should "do one thing".
    Look for situations where functions can be used to reduce code duplication (e.g. displaying the completed and required lists is very similar).
  • For efficiency, you should only load the items file once. Store the results appropriately in a list of lists that you can pass to any functions that need access to it.
  • Note that the menu choice should handle uppercase and lowercase letters.
  • Use exception handling where appropriate to deal with input errors (including entering numbers and selecting items).
  • Check the rubric carefully to see any other aspects of the coding that you will be assessed on.

Output Requirements:

Sample output from the program is provided below. Ensure that your program matches the sample output including spaces, spelling, and especially the formatting of the item lists. Think of this as helpful guidance as well as training you to be particular and pay attention to detail. The sample output is intended to show the full range of situations including user input error handling.

 

Sample Output:

The following sample run was made using a CSV file that contained:

Fish fingers,12.95,2,r
Metal detector,42.5,3,r
Coffee beans,40.0,1,r

 

Bold greentext below shows user input for this sample.

 

Shopping List 1.0 - by Lindsay Ward

3 items loaded from items.csv

Menu:

R - List required items

C - List completed items

A - Add new item

M - Mark an item as completed

Q - Quit

>>>c

No completed items

Menu:

R - List required items

C - List completed items

A - Add new item

M - Mark an item as completed

Q - Quit

>>>r

Required items:

0. Coffee beans         mce_markernbsp; 40.00 (1)

1. Fish fingers         mce_markernbsp; 12.95 (2)

2. Metal detector       mce_markernbsp; 42.50 (3)

Total expected price for 3 items: $95.45

Menu:

R - List required items

C - List completed items

A - Add new item

M - Mark an item as completed

Q - Quit

>>>M

0. Coffee beans         mce_markernbsp; 40.00 (1)

1. Fish fingers         mce_markernbsp; 12.95 (2)

2. Metal detector       mce_markernbsp; 42.50 (3)

Total expected price for 3 items: $95.45

Enter the number of an item to mark as completed

>>>1*

Fish fingers marked as completed
Menu:

R - List required items

C - List completed items

A - Add new item

M - Mark an item as completed

Q - Quit

>>>C

Completed items:

0. Fish fingers         mce_markernbsp; 12.95 (2)

Total expected price for 1 items: $12.95

Menu:

R - List required items

C - List completed items

A - Add new item

M - Mark an item as completed

Q - Quit

>>>a

Item name:    (blank spaces entered)

Input can not be blank

Item name: Watch

Price: $not much

Invalid input; enter a valid number

Price: $-50

Price must be >= $0

Price: $50

Priority: low

Invalid input; enter a valid number

Priority: 0

Priority must be 1, 2 or 3
Priority: 2

Watch, $50.00 (priority 2) added to shopping list

Menu:

R - List required items

C - List completed items

A - Add new item

M - Mark an item as completed

Q - Quit

>>>M

0. Coffee beans         mce_markernbsp; 40.00 (1)

1. Watch                mce_markernbsp; 50.00 (2)

2. Metal detector       mce_markernbsp; 42.50 (3)

Total expected price for 3 items: $132.50

Enter the number of an item to mark as completed

>>>2

Metal detector marked as completed

Menu:

R - List required items

C - List completed items

A - Add new item

M - Mark an item as completed

Q - Quit

>>>m

0. Coffee beans         mce_markernbsp; 40.00 (1)

1. Watch                mce_markernbsp; 50.00 (2)

Total expected price for 2 items: $90.00

Enter the number of an item to mark as completed

>>>two

Invalid input; enter a number

>>>2

Invalid item number

>>>0

Coffee beans marked as completed

Menu:

R - List required items

C - List completed items

A - Add new item

M - Mark an item as completed

Q - Quit

>>>M

0. Watch                mce_markernbsp; 50.00 (2)

Total expected price for 1 items: $50.00

Enter the number of an item to mark as completed

>>>0

Watch marked as completed

Menu:

R - List required items

C - List completed items

A - Add new item

M - Mark an item as completed

Q - Quit

>>>m

No required items

Menu:

R - List required items

C - List completed items

A - Add new item

M - Mark an item as completed

Q - Quit

>>>r

No required items

Menu:

R - List required items

C - List completed items

A - Add new item

M - Mark an item as completed

Q - Quit

>>>C

Completed items:

0. Coffee beans         mce_markernbsp; 40.00 (1)

1. Fish fingers         mce_markernbsp; 12.95 (2)

2. Watch                mce_markernbsp; 50.00 (2)

3. Metal detector       mce_markernbsp; 42.50 (3)

Total expected price for 4 items: $145.45
Menu:

R - List required items

C - List completed items

A - Add new item

M - Mark an item as completed

Q - Quit

>>>e

Invalid menu choice

Menu:

R - List required items

C - List completed items

A - Add new item

M - Mark an item as completed

Q - Quit

>>>Q

4 items saved to items.csv

Have a nice day :)

At the end of this run, the CSV file contained:

Fish fingers,12.95,2,c
Metal detector,42.5,3,c
Coffee beans,40.0,1,c
Watch,50.0,2,c

Reference no: EM131200222

Questions Cloud

Explain the pathophysiology of the disorders depicted : Identify the pathophysiology of the disorders presented in the scenarios, including their associated alterations. Consider the adaptive responses to the alterations.
Effects of given policy change on labor supply of workers : It is considering replacing this system with an EITC system. -Describe the effects of this policy change on the labor supply of workers with various incomes.
Describe the law of increasing opportunity costs : Draw the Production Possibilities Frontier (PPF). Suppose that the society produces 20 million tons of food and 8 million tractors per year. Is it operating on the PPF. If not, what factors may account for this? What is the total opportunity cost of ..
Draw a linear graph for the given model : By following a systematic procedure and using the linear graph, obtain a complete state-space representation of the given model. The outputs of the system are compressor speed ωc and the torque T transmitted through the drive shaft.
This program is a simple shopping list : This program is a simple shopping list that could also be used for TODOs or similar purposes. The program maintains a list of items in a file, and each item has:
Write a one- two page paper reflecting on the film : What did the film make you think about? Were there any surprises or information that was new to you? Did it change your perceptions about nursing?
What is the order of system and identify response variable : What variables would you measure (and feedback through suitable controllers) in order to improve the performance of the control system?
Cumulative wealth index and the geometric mean return : What common variable is used in the calculation of both the cumulative wealth index and the geometric mean return? How is the common variable calculated? How is it used in each?
What is the effective annual rate : An individual is borrowing $175,000 for a 20 year loan at 3.95% per year compounded monthly.  Immediately after the 104th monthly payment, the home owner plans to sell the house. How much money is owed back to the bank? What is the effective annual r..

Reviews

Write a Review

Programming Languages Questions & Answers

  Explain what purpose it serves

List three debugging techniques, within the debugger, that can be used to locate logical error in the Java code. For each of these tools, explain what purpose it serves and how it relates to the debugging process

  Design and implement class instance data for title of book

Design and implement a class called Book that contains instance data for the title, author, publisher, and copyright date. Define the Book constructor to accept and initialize this data.

  Develop program that simulates section of a restaurant menu

Develop a console program that simulates a section of a restaurant menu. Each item will have a different price and your program should define at least ten (10) items. You will need to obtain an order from the user who should provide their menu sel..

  Write a program that inputs an integer in the range

Write a program that inputs an integer in the range [-32767, 32767] from the Serial Monitor and checks to see if that number is a prime number. If the number is a prime number, have the LED on pin 13 turn on. If not, then turn the LED off.

  Write program to read data of four students from input file

Write C++ program which reads data of 4 students from the input file which name is given by user and displays summary report of students' marks on output file stdMarks.out"

  Travelling salesman problem

Travelling Salesman Problem on the L1-metric plane.

  Write ipo steps and detailed pseudo code for program

Write IPO steps and detailed pseudo code for program which will ask user to enter restaurant meal cost. The program should then compute the tax, tip on the restaurant bill,

  Create a program to draw image of archery target

Assume that you have been hired to produce a program which draws the image of the archery target-or, if you prefer commercial applications, a logo for national department store.

  What is operator precedence

What does it mean to say that a programming language is strongly typed?What is operator precedence?

  Track of position of a point in three-dimensional space

Specify, implement and design a class that can be used to keep track of position of a point in three-dimensional space. For example consider the point drawn at the topof the next coloumn. The point shown there has three coordinates

  Calculate and print the annual salary of the employee

Calculate and print the annual salary of the employee. suppose employee receive 6% increase in pay. Calculate and print net pay giving the pay rate and hours work. Suppose deductions amount to 9% of the gross pay.

  Provide a complete program that performs substitution cipher

Provide a complete program that performs a simple substitution cipher. The program should take plain text and a shift value and produce the encrypted text. Then it should take encrypted text and a shift value and produce the plain text once again.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd