CMPSC 101 Programming Assignments

Since the main course objective of CMPSC 101 is to use certain computer programming techniques to solve problems, you will have to complete a number of programs throughout the semester. It is essential that you follow the Programming Process. Create a test plan and write pseudocode before you begin to write or type out the actual C++ code. It is also important that you follow the course Coding Standards when you write each program so that it is easy to read your program and so that others can understand your code.

The Programming Process - You must conscientiously follow these steps to be successful. Students who do not have the patience to follow the steps WILL have difficulty.

1. Define the problem and understand the given specifications. Create a test plan.
2. Develop an algorithm by writing pseudocode.
3. Code the program by writing it out on paper first.
4. Test and debug the program.
5. Document and maintain the program.

Coding Standards - Hopefully, you will become a better problem-solver throughout this course. However, even if you write a program that displays the proper results, you may lose points if you do not follow the Coding Standards even to the point of receiving a lower letter grade. Read these guidelines thoroughly. If you have any questions, be sure to consult the instructor. Be sure to read the common errors that former CMPSC 101 students have made in the past on their programming assignments.

This rubric will be used to grade your programs.

For each assignment below, be sure to immediately ask the instructor about the specifications if you have any questions. You must choose the proper variable data types for your variables so that the final answer is accurate. Include explanatory input prompt messages where appropriate so that the user knows exactly what to type as inputs. Make sure that your outputs are clearly explained with a word or phrase. Make sure that a dollar symbol is displayed in front of amounts of money.


Assignment #1:

Follow the compiler instructions to create your first C++ source file named a1.cpp. Type the code below exactly as it appears.

// type your name here
// a1.cpp
// type the day of the week that you have class

#include <iostream>
#include <cstdlib>
using namespace std;

int main()
{
   cout << "hello world" << endl;
   system("pause");

   return 0;
}// end of main

Compile the program by clicking the Build/Compile menu command.
Debug the program and remove any errors if necessary.
Execute
the program by clicking the Debug/Start without Debugging menu command.
Print the source code by clicking the File/Print menu command
Turn in the hardcopy printout at the beginning of class on the due date.
Upload copies of the source file (.cpp) and executable file (.exe) to the appropriate Angel drop box under the Lessons tab by the beginning of class on the due date.


Assignment #2:

On online retailer has hired you to write a program to calculate the total cost of a customer's purchases. The customer may order books, movies, and peanuts. Books are $9 each. Movies are $13.97 each. Peanuts are sold at $1.72 per pound and can be purchased by the tenth of a pound. The shipping cost for each book is $0.95. The shipping cost for movies is 4% of the movie subtotal portion of the order. The shipping charge for peanuts is 30 cents per pound of peanuts ordered.

The program must prompt the user to input the number of books, movies, and peanuts (in lbs.) that he would like to purchase and obtain those amounts in that specified order. The program must then output the total cost of the three orders rounded to the nearest whole dollar with aesthetic, nicely formatted cash register receipt built with ASCII art (*, -, _, $, ^, & other symbols) that includes your whole name as the cashier and other fictitious info (name of store, date, city, state, gas points, etc.) Here are examples of ASCII art receipts: Example 1, Example 2. The final price must be easy for the instructor to find on this "receipt."

Your program must be consistent with any sample test plan cases that may have been developed in class such as those found on Test Plan Worksheet #1

The program must follow our Coding Standards.

You must add the line    system("pause");    right before     return 0;      in order to receive any credit for this assignment.

Preconditions:

You must hand in the hardcopy source code for this assignment. Staple multiple pages together, if applicable.

You must also upload copies of the source file (named a2.cpp) & the executable file (named a2.exe) to the appropriate drop box in Angel by the beginning of the class period on the due date. You will lose points if any file is named incorrectly.


Assignment #3:

Modify Assignment #2 with the following, additional specifications. The program must use a loop to present the customer with the following exact menu allowing him to make one or more orders for each of the three products if he desires.

1 Books
2 Movies
3 Peanuts
4 Checkout


The customer is allowed to make two or more separate orders for the same product. For example, the customer may order 3 books and 2 movies but no peanuts. Or, the customer could order 5 books, 1 pound of peanuts, and 3 movies in that order. Or, the customer could order 6 books, 3 movies, and then 2 more books. The customer may choose menu option #4 to exit the program at any time, even if he has made no purchase. Also, display the message "Invalid input." if the user inputs a quantity that is less than 0 or greater than 50 and immediately display the menu again. Also, if the user inputs a menu choice below 1 or greater than 4, display the message "Invalid input." and immediately display the menu again. So another example order could find the customer attempting to order 51 books followed by the program displaying "Invalid input." and the menu being displayed. The customer could then order 2 movies and exit the program having ordered only 2 movies and no books. Again in this assignment, you only have to display the final total cost but it must be rounded to the nearest penny with aesthetic, nicely formatted cash register receipt built with ASCII art (*, -, _, $, ^, & other symbols) that includes your name as the cashier and any other interesting fictitious info (name of store, date, city, state, gas points, etc.) The final price should be easy for the instructor to find on this "receipt."

You must use at least 2 functions other than the main function. The functions must be appropriate and effective based on what we have learned about the purpose of functions.

No pseudocode or test plan must be submitted with this assignment.
Your program must be consistent with any sample test plan cases that may have been developed in class such as those found on Test Plan Worksheet #2
The program must follow our Coding Standards.

You must add the line    system("pause");    right before     return 0;      in order to receive any credit for this assignment.

Preconditions:

You must hand in the following on separate pages stapled in this specified order:

  1. The hardcopy source code for this assignment. Staple multiple pages together, if applicable.

You must also upload copies of the source file (named a3.cpp) & the executable file (named a3.exe) to the appropriate drop box in Angel (look under the Lessons tab) by the beginning of the class period on the due date.


Final Project:

See the specifications here.

This rubric will be used to grade the project. This link will allow you to save it as a pdf or Word document which you can either fill out with pen, scan and eventually upload as a pdf to the drop box or type answers and upload as a pdf.