CS 210

FUNDAMENTALS OF COMPUTER SCIENCE I

 

Instructor: Philip Durr,  Office: By Appointment, e-mail: pdurr@bcc.ctc.edu

 

Text: Problem Solving, Abstraction, and Design in C++ - Friedman / Koffman ( 3rd ed)

 

Computer Lab: N-250 (In the NWCET Building!)

 

Class Web URL: http://prime.bcc.ctc.edu/MG/210/

 

ALL STUDENTS IN THIS CLASS MUST have access to the Internet, and a functioning E-mail account! Accounts are available to all registered students at BCC.

 

COURSE DESCRIPTION: This course will provide an introduction to a disciplined approach to problem solving methods and algorithm development using the C++ programming language. The student will be introduced to procedural and data abstraction. Program design, coding, debugging, testing, and documentation using good programming style will be stressed.

 

COURSE OBJECTIVES: Students will demonstrate competency by performance on tests and lab projects. Competency will be measured as follows:

 

Exams and Quizzes: count toward 130 points. Two exams will be given (50 points each). Three quizzes (10 points each) will also be given. There will be NO make-up tests.

 

Programming Assignments: Count toward 160 points: there will be seven programming projects, 15-30 points each. E-mail to pdurr@bcc.ctc.edu your project’s source file(s) by midnight on the Saturday after class the week the assignment is due. Any exceptions to this rule must be approved by the instructor PRIOR to the assignment’s due date. Programming projects will be graded on readability, documentation, work, completeness, clarity and style. All program submissions must be in the format shown in programming assignment 0. Fifty percent of your projects grade will be based on the requirements, analysis, and design of the project. The remaining points will be based on algorithm and code implementation, overall design, readability, clarity, documentation and overall stability.

 

Problem Solving Assignments: Count for 10 points of your grade. Problem solving submissions must in the form of a word document and will be graded on clarity, accuracy and completeness.

 

Grading: Course grades will be determined with the following percentage chart:

 

 

95 – 100

A

90 – 95

A-

88 – 89

B+

85 – 87

B

80 – 84

B-

78 – 79

C+

75 – 77

C

70 – 74

C-

67 – 69

D+

60 – 66

D

 

 

Below 60

F

 

 

 

 

 

ATTENDANCE - Attendance is not mandatory, it is VERY strongly recommended. It is the student's responsibility to obtain any material/assignments that may have been missed.

 

CHEATING:  All work is to be the individual work of each student. You may calibrate with other students on programming projects, however your project’s design and code must be your own work. "Sharing" work is not permitted and those who "share" work will receive a zero for the work involved, including exams. Repeated activity of this nature will be reported to the Dean of Student Services for further action. Be advised that such reports may be appealed.

 

 If you require accommodation based on a documented disability,
emergency medical information to share, or need special arrangements in case of emergency evacuation, please make an appointment with me as soon as possible.

If you would like to inquire about becoming a DSS student you may call564-2498 or go in person to the DSS (Disability Support Services) reception area in the Student Services Building. 

 

CS 210 SCHEDULE - Subject to CHANGE!

 

Week Of

Topics

Chapter

Sept. 23

PROBLEM SOLVING Intro to Programming; The C++ Language

1, 2

Sept 30

MORE Problem Solving TOP - DOWN DESIGN, FUNCTIONS

PROGRAM 1 due

3

Oct. 7

SELECTION

Quiz #1, PROGRAM 2 due

4

Oct. 14

REPETITION

PROGRAM 3, due

5

Oct 21

MODULAR PROGRAMMING

Quiz #2

6

Oct 28

Mid Term

PROGRAM 4, due

 

Nov 4

SIMPLE DATA TYPES, STRUCTURES, ARRAYS, and STRINGS, FORMATTING and FILES

 7, 8, 9

Nov 11

CLASSES, USER-DEFINED CLASSES,

PROGRAM 5, Due

10

Nov 18

INTRO to SW ENGINEERING

INTRO-TO JAVA

Quiz #3,
PROGRAM 6, Due

10, 11, 1, 2, 3

Nov 25

Holiday

 

 

Dec 2

Finals week – FINAL
The Infamous Ball Problem due, PROGRAM 7, Due

All

CS 210 - Program #0

Not Required

 

While this program is not required, it is strongly suggested. This assignment will assist you in becoming familiar with the programming environments in the IT Lab (N-209) and the required format for your source. Using the editor of your choice, type in the sample program below, then Compile, Link and run the program.

 

/*

     Student:          Philip Durr, Program0

 

Requirements: Write a program that displays the sum

              of two integer numbers entered by the

              user.

 

Analysis:     Inputs:

                integer number 1, variable name one

                integer number 2, variable name two

 

              Outputs:

                The sum of integer variable one and

                Variable two

 

Design:       Step 1 - Prompt the user for integer

                       number 1

              Step 2 - Get number one from the user

              Step 3 - Prompt the user for integer

                       number 2

              Step 4 - Get number two from the user

              Step 5 - Add the two numbers together

                       and store the result in the

                       variable sum.

              Step 6 - Display the contents of

                       variable sum on the display.

*/

 

/* Implementation */

 

#include <iostream>

 

using namespace std;

 

void main()

{

    int one;    //storage for the first integer

                //entered by the user

    int two;    //storage for second integer entered

                //by the user

    int sum;    //storage for result of adding the

                //first and second integers

 

    cout << "Enter first integer:";

    cin >> one;

 

    cout << "Enter second integer:";

    cin >> two;

 

    sum = one + two;

 

    cout << "The result is: " << sum << endl;

}

 

/*

    TESTING:

 

        CASE 1

 

            Enter first integer:10

            Enter second integer:5

            The result is: 15

            Press any key to continue

 

 

        CASE 2

 

            Enter first integer:25

            Enter second integer:-10

            The result is: 15

            Press any key to continue

 */

 

CS 210 - PROGRAM #1

15 Points

 

Write a program to convert a temperature in degrees to Fahrenheit to degrees Celsius. To convert from degrees Celsius to degrees Fahrenheit use the formula Celsius = (5/9) (Fahrenheit-32). Your final submission must be in the format of program 0 and include your requirements, analysis, and design.

 

CS 210 - Program #2

15 Points

 

Write a program to take a depth (in kilometers) inside the earth as input data; compute and display the temperature at this depth in degrees Celsius and Fahrenheit. The relevant formulas are:

 

Celsius = 10 (depth) + 20, Celsius temperature at depth in km

Fahrenheit = 1.8 (Celsius) + 32

 

Your program must implement two functions. The interface and purpose of these functions are as follows:

 

float CelsiusAtDepth(float depthInKm)

 

PURPOSE: Computes and returns the Celsius temperature at depthInKm.

 

 

float ToFahrenheit(float temperatureCelsius)

 

PURPOSE: Converts a Celsius temperature to Fahrenheit.

 

Make sure that you include the appropriate function comment header before each function. Be SURE to do your Analysis and Design phases well, and Document well!

 

CS 210 - Program #3

20 Points

Write a menu driven program that can be used to calculate the weighted average grade for students taking CS210. The programs user should first be presented with the following menu:

----------------------------------------------

CS210 Grade Calculation Program

----------------------------------------------

1 – Enter Scores and calculate grade

2 – Help on using this program

3 – Exit program

Select Option:

----------------------------------------------

When the user selects menu option 1 they need to first be asked the students name and then a series of questions to collect the various test, quiz, and project scores for the student. The weighted grade average is then calculated by adding all of the students quiz, exam, problem solving and programming assignment scores and dividing this total result by the total number of points possible in the class 300. This result is then compared with a series of “if then else” statements against the grading table for this class in order to display the student’s letter grade. The user should then be presented with the programs menu.

If the user selects option 2, then they should be presented with instructions on how to use the program and then returned to the main menu. Finally, the programs user can exit the program by selecting menu option 3.

 

CS 210 Fall 1998 - Program #4

20 Points

 

Write a Program that models a simple calculator. Each data entry line should consist of a valid operator (from the list below), and the right-hand operand. Assume that the left-hand operand is the accumulated value in the calculator, with an initial value of 0.0.

 

Acceptable operators are, + ..Add, -..Subtract, * ..Multiply, / ..Divide, ^ ..Power (raise left operand to the power of the right operand), q or = ..Quit

 

Your Calculator should display the accumulated value after each operation. A sample run might be:

 

+ 5.0

Result so far is 5.00

^ 2

Result so far is 25.00

/ 2.0

Result so far is 12.50

Q 0

The final result is 12.50

 

Your program must (define and call) at least THREE functions, two of the functions must be named:

 

  1. a function that displays instructions to the user called DisplayInstructions.
  2. a function DoNextOperation that has 3 input parameters (the operator, the operand, and the current accumulated value), and returns the new value for the accumulated value. An alternative implementation may use 2 input parameters (operator and operand), and 1 input/output parameter (the accumulated value)
  3. and at least one other function - of your choice! Make sure that it does something useful and is well documented.

 

 

CS 210 - Fall 2000 - Program #5

30 Points

 

An ISBN (International Standard Book Number) identifies a unique publication. An ISBN is ten digits. The first nine digits must be decimal digits (0...9). The tenth may a decimal digit or the letter X, according to the checksum, discussed below. Three single dashes may be between any of the characters, but an ISBN must not begin or end with a dash.

 

Some example ISBNs:

0-201-88337-6

0-13-117334-0

0821211315 (no dashes ok)

1-57231-866-X

 

The last character of an ISBN number is a checksum. The checksum is the determined by the first 9 digits; it is computed by taking modulo 11 (the remainder after dividing by 11) of the sum of each digit multiplied by its position in the ISBN. The letter X corresponds to a value of 10.

 

Here are two ISBNs and the calculations that show how the check sum is determined:

 

0-201-88337-6 -> (0*1 + 2*2 + 0*3 + 1*4 + 8*5 + 8*6 + 3*7 + 3*8 + 7*9) mod 11 = 6

1-57231-866-X -> (1*1 + 5*2 + 7*3 + 2*4 + 3*5 + 1*6 + 8*7 + 6*8 + 6*9) mod 11 = 10 (X)

 

For more info, check out:

 

http://www.isbn.org

http://www.amazon.com, Try a book search by ISBN

 

Some invalid ISBNs:

 

0-201-8A337-6 (bad digit)

0-201-88337-63 (too many digits)

0-201-88-337-6 (too many dashes)

0-201883376 (not enough dashes)

0-201-88337-3 (wrong check sum)

-013-117334-0 (beginning or ending dash)

157231--866-X (sequential dashes)

013-1134-0 (too few digits)

 

Write a menu driven program that will verify ISBNs either from user input or from file input (use default filename = isbntest.txt). The file should consist of an integer value that specifies the number of ISBN's to follow (max of 20),  followed by the isbn numbers, for example:

6

0-201-88337-6

0-13-117334-0

157231--866-X

-013-117334-0

0821211315

1-57231-866-X

 

Program Assignment #6

30 Points

 

Write a program that:

 

Plays the game of "Hangman" - wherein the user tries to guess the proper letters forming a word selected by the computer, or by a second user. Each time an incorrect letter is chosen, a new portion of a hanged man is drawn - if the fully hanged man figure is drawn, the user has lost! If, on the other hand, the user guesses the word correctly before then, the user wins.

 

  1. The user should be able to choose between playing against the computer, or against another human. The only difference will be how the word to be guessed is selected: If playing against the computer, the computer will choose from a built-in list of words, picking one of them at random; If playing against another human, the human hangman will type in a word (a string - a character array).

 

  1. The user (either the guesser or the hangman) should be asked for the number of incorrect guesses to allow the guesser... within the range 4 to 10 inclusive.

 

 

  1. Before each guess entered by the user, the program should

 

1.      Display the letters already chosen

2.      Display the number of guesses left

3.      Display the portion of the word already guessed, inserting an * (asterisk) for each letter not yet guessed.

4.      (Optional) Display the hanged man portions already "drawn" - starting with a scaffold, then the head, body, arms, legs, face, etc...

 

  1. The user enters a character; the program will then indicate if an incorrect character was chosen:

 

1.      A letter already chosen

2.      Any non-alphabetic character (such as ?, /, 4, $, etc.) (Hint: see documentation on ctypes.h - especially isalpha())

 

  1. If the user has correctly guessed a letter that appears in the word, the displayed word (with asterisks) is updated, replacing the proper asterisks with the correctly guessed letter. For example, if the word were "EAGLE" and the user guessed "E", both the first and last letters would be filled in : E***E.

 

  1. If the user has correctly guessed the entire word without using all of the allowed incorrect guesses, a congratulatory message (and, optionally, bells and whistles!) Should be displayed. If, on the other hand, the user runs out of incorrect guesses, an appropriate message of condolence should be displayed.

 

 

  1. Upon termination of a game the program should prompt the player if another game is wanted - an 'n' or 'N' will terminate the program, otherwise it will loop back, select another word, and do it all again!!

 

CS 210 Program #7

Points 30

 

SPECIFY, DESIGN, and IMPLEMENT a CLASS that can be used to simulate a lunar Lander, which is a small spaceship that transports astronauts from lunar orbit to the surface of the moon.

 

THEN, Write a PROGRAM using that class to implement a lunar Lander game - allowing the user to interact with the Lander, attempting to achieve a safe lunar landing.

 

When a lunar Lander is constructed, the following items should be specified, with default values as indicated:

 

 

Don't worry about other properties (such as horizontal speed).

 

The Lander has accessor member functions that allow a program to retrieve the current values of any of the seven items listed above.

 

There are two mutator functions:

 

 

 

The following formulas are APPROXIMATIONS, that are reasonably accurate over a small period of time:

 

 

·        Altitude change changes by t * v where v is the vertical velocity of the Lander

 

It is suggested that you calculate the changes in the order listed. After these adjustments, two other things need to be done:

 

 

 

Your PROGRAM should then use this class, and allow the user the opportunity to specify beginning values for the data items, and be asked for periodic updates for the current fuel flow rate. ( You might have the user enter a number from 0 to 10 for the flow rate, and then internally divide by 10, and use that as the flow rate. )

 

The Infamous BALL PROBLEM!

Points 10

 

Solve the following problem, and submit not only the solution, but also a record of your work. Explain the problem-solving techniques you used, obstacles encountered, dead ends, and any insights gained, and what you learned from the exercise.

 

The Problem:

 

"There are 12 balls, identical in appearance, but one is either heavier or lighter than the others. Using a balance scale, and using it only 3 times, isolate the odd ball, and be able to say in which way it differs from the others."

 

Make your presentation as professional, complete, precise, and neat as possible.

 

Please start on this problem immediately - it may take a long time to complete.