15. Final review and projects

Review Topics


General Information

Housekeeping

  • Make sure you follow along with this page linked in Canvas
  • Please keep your microphone off unless you are asking a question
  • Please turn on camera if you can (optional)
  • Use chat if you would like to comment or ask questions

Announcements

See Announcements link in Canvas for course information. Here are some other reminders:

Homework Help

Questions from last class?

Project Questions?

  • Anyone completed their project and ready to present or show it to me early?
  • Do not forget to submit your project before presenting

Final Exam Approaching

15.1: Using the Linux Terminal

  • We have used the Terminal of Replit in the past (see Lesson 4.2.1)
  • We used the Terminal for compiling:
    g++ -Wall -Wextra -Wpedantic -o main main.cpp
    

    Where the parts of the command mean:

    • g++: The name of the compiler program
    • -Wall: Enable all the warnings about questionable code (like /* /* */)
    • -Wextra: Print extra warning messages for some problems (like unused-parameters)
    • -Wpedantic: Show all the warnings demanded by strict ISO compliance
    • -o main: After -o type the name of our executable file
    • main.cpp: The name of our source code file, which must end in .cpp
  • To run a compiled program in the terminal window we enter:
  • ./main
    
  • In this section we create a text file in the terminal window and then work with the file
  • Working with the Terminal is important for the final exam

15.1.1: Creating a Text File in the Terminal using Vim

By using the Terminal, we may create a text file for use in programs that require files.

  1. Type vi filename.txt into the Terminal and press ⏎ Enter.

    The "vi" part of this command selects the Vim text editor as the program to use. Replace "filename" with the name you wish to assign to your new file. For example:

    > vi infile.txt
    
  2. Press your computer's i key. Doing so will place your document in "Insert" mode so you can enter text as needed.

    You should see -- INSERT -- pop up at the bottom of the window when you press the i key.

  3. Enter your file's text. Either type or copy-paste text like the following:
    China plate
    5.99
    30
    Hand mirror
    4.49
    20
    Glass apple
    7.75
    10
    

    In Windows, paste into the Terminal by right-clicking and selecting Paste.

  4. When finished entering text, press the Esc key. It's typically in the upper-left corner of your computer's keyboard. This keypress will stop the insert mode.

    An alternative to Esc is Ctrl+[ (Ctrl and Left Square Bracket "[") together.

  5. Type :wq into the Terminal and press ⏎ Enter to save your document and quit Vim.
    •  :  enters command mode
    • w writes to the file
    • q  quits the Vim program

15.1.2: List Files in the Terminal

Once we create a file, we verify it exists .

  1. Type ls into the Terminal and press ⏎ Enter.

    The ls command means "list files".

  2. The Terminal lists all the files and folders like the following:
    > ls
    infile.txt  main.cpp
    >
    

15.1.3: Viewing File Contents in the Terminal

To view the contents of a file we use the more command.

  1. Type more filename.txt into the Terminal and press ⏎ Enter.

    Replace "filename" with the name you wish to assign to your new file. For example:

    vi infile.txt
    
  2. The Terminal lists output like the following:
    > more infile.txt
    China plate
    5.99
    30
    Hand mirror
    4.49
    20
    Glass apple
    7.75
    10
    >
    

Notice the newline at the end of the file. Without the newline the prompt would appear after the 10, like:

10>

If you see the prompt after the last file entry, redo the input file to ensure the last entry is followed by a newline.

Exercise 15.1: File IO with Text Files (15m)

In this exercise we read from a file created in the terminal window.

For this exercise we break into teams. Within the team, work with each other to develop a solution. When the team has finished, choose one member to show your solution to the class by sharing your screen. The instructor will ask one team to share their solution.

Specifications

  1. Start Replit and create the following text file using the Terminal window as shown above in Creating a Text File in the Terminal using Vim
    China plate
    5.99
    30
    Hand mirror
    4.49
    20
    Glass apple
    7.75
    10
    

    Ensure there is a blank line at the end of the file.

  2. Copy the following code into the Replit code editor.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    
    #include <fstream>   // for file I/O
    #include <iostream>  // for cout
    #include <cstdlib>   // for exit()
    using namespace std;
    
    int main() {
        ifstream fin;
        ofstream fout;
    
        fin.open("infile.txt");
        if (!fin.is_open()) {
            cout << "Input file failed to open.\n";
            exit(1);
        }
    
        fout.open("outfile.txt");
        if (!fout.is_open()) {
            cout << "Output file failed to open.\n";
            exit(1);
        }
    
        string line;
        while(getline(fin, line)) {
            fout << line << endl;
        }
    
        fin.close();
        fout.close();
        cout << "Done copying infile.txt to outfile.txt" << endl;
    
        return 0;
    }
    
  3. Run the code and verify you see the following output.
    Done copying infile.txt to outfile.txt
    
  4. List the files in the Terminal window:
    > ls
    infile.txt  main  main.cpp  outfile.txt
    >
    
  5. List the contents of outfile.txt in the Terminal:
    > more outfile.txt
    China plate
    5.99
    30
    Hand mirror
    4.49
    20
    Glass apple
    7.75
    10
    
    >
    
  6. Copy the contents of outfile.txt and save the file as "outfile.txt", and to submit the file to Canvas.

Note: Replit may delete the extra files after some period of time.

15.2: Final Exam Preparation

Important Final Exam Information

Schedules (Spring 2021 Final Examinations)
Location: online classroom
Scheduled Dates and Times:
  • 11:30am Class: Tuesday, May 18 @ 10:00am-12:50pm
  • 2:30pm Class: Thursday, May 20 @ 1:00pm-3:50pm
  • You must attend the exam at the scheduled time or you will receive a score of zero (0)
    • Except for unforeseeable emergency and justifiable reasons
  • Be on time as you can only work on the exam during the scheduled time
  • The final exam is a Lab Practical
    • See practice exam for examples
  • This means that you must write code for the exam
  • You need to solve a series of programming problems during the exam
  • Successfully completing each problem is worth some stated number of points
  • The exam covers material from the entire course
  • We will take the exam in Canvas.

15.2.1: Administration and Exam Rules

  • Exam length is about 2 hours.
  • Exam is closed books, closed homework, and closed notes except one 3" x 5" card of handwritten notes.
  • Exam work area must be clear: only a computer, 3" x 5" card, and one sheet of blank scratch paper.
  • Your exam computer must have the LockDown Browser installed for the exam
    • Verify your computer with the Pre-Final Computer Check quiz
  • We will start the exam in a Zoom room to answer questions, verify 3x5 cards and scratch paper, and position devices
  • Join the Zoom room using your cell phone--not your computer
    • The browser interfers with Zoom during exams
    • Install the Canvas and Zoom apps on your phone
  • No computer applications open except the LockDown Browser.
  • Must NOT use the computer to:
    1. View documents on the Internet
    2. Look at pre-existing code
    3. Open documents of any kind
    4. Send messages to anyone but the instructor (instructor via Zoom chat)
  • No devices near work area including but not limited to earbuds, headphones, or cell phones, except for one cell phone positioned for Zoom call.
    • Touching a cell phone during the exam == automatic fail
    • The exam includes a built-in calculator
  • Other allowed computer uses are entering, compiling and running code using an online compiler provided in the exam.
    • Cannot use any other compiler or editor except the one provided
  • Start the exam with the LockDown Browser
  • Must NOT communicate with anyone but the instructor during the exam
    • Find a separate room or space for the exam if possible
    • Make certain other people in your home know not to disturb you during the exam
    • Students are responsible for not invading third party privacy rights with their webcam or phone
  • Send questions or other messages to the instructor during the test via Zoom chat

About Audio and Video

  • In normal class meeting I do not require audio or video.
  • However, the test is not a normal class meeting
  • Audio and video is required during the test
  • Students are responsible for selecting private spaces for testing
  • Students must ensure that any recordings do not invade the privacy rights of any third party

About Compiling

  • Code that does not compile contains an error
  • When given the tools to compile, your code must compile for a good score
  • Expect a substantial penalty if your code does not compile
  • Also expect to lose points for every error in the code
  • If you are having problems compiling, comment out the parts that do not compile
  • Partial credit is available if you comment out your problem code
  • However, I do recognize that file IO will be limited during the exam
  • For file IO I will ignore some minor errors in output files

3"x 5" Card Requirements

  • Put your name on your card
  • Maximum card or paper size is 3 inches by 5 inches
  • You may use both sides of the card
  • Notes must be handwritten and NOT photocopied
  • No more than three statements in a code sequence on the card — only snippets
  • Any 3" x 5" cards violating these rules will be denied use before the exam

15.2.2: Test Preparation Resources

You have many resources to help you review and prepare for the exam shown below.

  1. Textbook
    • Table of contents: expand and review the sections for each chapter to locate information
    • Search: type in keywords to find topics, click links and search in the page
    • Participation Activities (PAs): Review the PAs as needed to refresh your memory of concepts
    • Challenge Activities (CAs): Verify you know how to write the code snippets
  2. Lesson notes
    • In-class exercises: review the practice problems we worked on during class
    • Your notes: written down before, during or after class
  3. Lab projects
    • Review the lab projects you completed each week
    • Review the instructor's project solutions (in Canvas) and compare with your solutions
  4. Practice exam problems sets
    • Recursion problems turned in for Lab 13.1--one of them is on the exam
    • Review problems turned in for Lab 15: Final Exam Review Problems (in Canvas)
    • Practice exam (in Canvas)--important!
    • Practice debugging code with practicebugs.cpp and products.txt
  5. Instructor, SI and tutors: ask questions
    • Student hours: see Canvas Home page
    • SI study sessions
    • Q & A discussion
    • Email
    • CS tutoring hours: (tutoring resources)
  6. 3x5 Reference card

3"x5" Card Requirements

  • Put your name on your card
  • Maximum card (or paper) size is 3 inches by 5 inches
  • You may use both sides of the card
  • Notes must be handwritten and NOT printed or photocopied
  • No more than three statements in a code sequence on the card — only snippets
  • Any 3" x 5" cards violating these rules will be denied use before the exam
  • If uncertain, email me a question about or photo of the card before the exam

15.2.3: Exam Topics

  • The final exam is cumulative -- you should know everything we have covered
  • However, the focus is writing code for what we have learned since the last exam
  • See below for newer exam topics

Newer Code You Must be Capable of Writing

  1. Defining and initializing vectors (Week 7)
  2. Accessing vector elements (Week 7)
  3. Finding and changing the size of a vector (Week 7)
  4. Processing vectors using loops (Week 7, Week 9)
  5. Declaring and defining functions (Week 8, Week 9)
  6. Coding vector parameters and return values (Week 9)
  7. Coding common vector algorithms such as searching for, inserting and deleting elements (Week 9)
  8. Declaring class types (Week 11)
  9. Declaring and defining member functions (Week 11)
  10. Coding constructors with and without parameters (Week 11)
  11. Constructing objects and calling their functions (Week 11)
  12. Modifying (changing) values in an object (Week 11)
  13. Writing set and get functions of classes (Week 11)
  14. Processing vectors of objects using loops (Week 11)
  15. Opening a file stream for reading or writing (Week 12)
  16. Reading different types of data from a file (Week 12)
  17. Loading data from a file and saving it in variables, vectors and objects (Week 12)
  18. Writing data from a vector and saving it in a file (Week 12)
  19. Developing recursive functions (Week 13)
  20. Working with files in the Terminal (Week 15)

Exercise 15.2: Preparing for the Exam

Practicing for an exam is important to doing our best. We do not want to wait until the night before to prepare. To help us practice we will review some problems during class. Treat the practice like homework -- because it is!

For this exercise we break into teams. Within the team, work with each other to develop a solution.

Note that this exercise is longer than most and has several parts. In your teams, stop after each part and compare and discuss work. The instructor will move between rooms, as usual, to answer questions. When you are finished working on the exercise you are free to leave.

Before starting the exercise, we allow early sampler project presentations. Does anyone have an early project presentation--either public or private? If so, send me a chat indicating public or private. If public you will need to share your screen and talk though your project as discussed below in Presenting Your Project. If private, we will use a breakout room while this exercise is progressing.

Specifications

  1. In Canvas, open Lab 15: Final Exam Review Problems.
  2. Next, start Replit to develop your code.
  3. After working on your lab, copy your code into a text editor and save the file as "finalwork.cpp".
  4. If completed with the lab, debug the following code to improve your debugging skills:
  5. If completed with the above, take the Practice Final Exam in Canvas

15.3: Project Presentation

Before the Presentation

  • Submit the following to Canvas before the presentation:
    1. README.txt file containing the project report
    2. All source code (i.e. .cpp files)
    3. Any other files needed to make your program function
  • Remember that there are no late submittals accepted after the presentation time
  • If you have problems completing your project, then turn in what you have and present
  • Without presenting you get a much lower score

Project Setup

  • Verify your code compiles and your project loads its files
    (Replit not required if you have another way to compile)
  • Prepare your computer to share it's screen
  • If you get stuck or do not know what to do, ask for help

Presenting Your Project

Present the following information:

  • Introduce yourself and state the purpose of your project
  • Compile your program completely and be sure to include all the warnings:
    g++ -Wall -Wextra -Wpedantic -o main main.cpp other.cpp files
    
  • Quickly demonstrate your project, explaining aspects as you go
    • Show and explain all extra-credit features
    • Explain how the extra credit and interesting features work
    • Show the code for any recursive functions, binary search, and when needed to explain features
  • Limit the presentation to 5 minutes or less

After the Presentation

  • Feel free to leave (or stay) after your presentation
  • You can present to the instructor alone after the other presentations are through
  • Remember to study for the final!

Arranging the Private Presentations

  • For private presentations, the instructor will enable the waiting room.
  • If you would like to be among the first called, put your name in Chat when signaled by the instructor
  • Next we all leave and rejoin the meeting.
  • You will be in a waiting room and invited in for instructor review one project at a time.
  • Continue to work on your final lab, or other projects, while waiting
  • If you miss your turn, rejoin the meeting to get added back to the queue

End of Course Survey

Reminders

Study for the final!

 

Last Updated: May 17 2021 @00:48:25