Contents

Overview

Your job in this assignment is to create the third iteration of the Notes program. You are going to redesign your program to use arrays and loops. The program should run from the command line just like in PA2, except rather than only prompting the user five times, PA3 should keep asking the user until he or she enters q to quit.

Step 1

The first thing you should do is to refactor your code to use an array to store the set of notes. By using an array to store the notes, you can easily increase the number of notes you store, and accessing them is fast—no conditionals needed! You should update the code that prints out the notes to use a for loop. You'll need to keep track of the number of notes (hint: this should probably be a constant) so that 1. you know when to stop when print out all the notes in your for loop and 2. you can check if the the note the user wants to modify or delete exists.

Step 2

Rather than manually prompting the user for commands five times, you should modify your code to use a do-while loop that keeps prompting the user until he or she enters q. The implications of this are pretty cool—with a loop, you can prompt the user tens, hundreds, and even thousands of times and write fewer lines of code than you did to prompt the user five times as you did in PA1 and PA2.

Here's an example of my version of PA3 running (my input is in orange just to make it obvious):

$ ./pa3 

Current notes:
Note 1: 
Note 2: 

Would you like to [d]elete|[m]odify a note or [q]uit? m
Which note would you like to modify? 1
Please enter the new note: Finish homework
Please enter the new note's priority level: 1

Current notes:
Note 1: Finish homework (Priority 1)
Note 2: 

Would you like to [d]elete|[m]odify a note or [q]uit? m
Which note would you like to modify? 2
Please enter the new note: Hit the gym
Please enter the new note's priority level: 2

Current notes:
Note 1: Finish homework (Priority 1)
Note 2: Hit the gym (Priority 2)

Would you like to [d]elete|[m]odify a note or [q]uit? d
Which note would you like to delete? 1

Current notes:
Note 1: 
Note 2: Hit the gym (Priority 2)

Would you like to [d]elete|[m]odify a note or [q]uit? q
Okay, goodbye!
(Back to top)

Requirements

Start by copying your PA2 and work from there.

(Back to top)

Extra credit

Make sure you indicate in your program header (in the description) whether you've attempted the extra credit, otherwise I won't count it!!!

EC-1 (3 points)

Make your program hold a user-defined number of notes.

EC-2 (5 points)

Add some extra functionality, like the ability to copy or move notes. You can be creative here, but make sure you let me know ahead of time what you want to do so I can let you know if it's sufficient.

(Back to top)

Submissions

Everything should be uploaded to Canvas by the deadline posted.

(Back to top)