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. Write a test plan and 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 miss many 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 and your textbook. Be sure to read the common errors that former CMPSC 101 students have made in the past on their programming assignments.

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.

This rubric will be used to grade your programs.


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 and debug the program if necessary. Execute the program. Print the source file by clicking the Visual C++ File/Print... menu command and submit it by the due date.

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


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.99 each. Peanuts are sold at $1.80 per pound and can be purchased by the tenth of a pound. The shipping cost for each book is $1.06. The shipping cost for movies is 5% of the movie subtotal portion of the order. The shipping charge for peanuts is 50 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.

Your program must be consistent with any sample test plan cases that may have been developed in class and 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.