Monday, October 31, 2011

Lab 11 - circle calculations

As one of the requirements to earn a B- or higher, you must complete exercise 6 on pp 341-342, which requires you to solve a set of problems regarding the calculation of properties of a circle.

You need to write three functions; these are their headers:

   double radius(double x1, double y1,
                 double x2, double y2)
   double circumference(double r)
   double area(double r)

Homework 4 - is vowel

You are to complete exercise 2, p 340, writing a program which contains a user-defined function, isVowel. This is its header:

   bool isVowel(char c)

The user should be prompted to enter a character. Your function isVowel must determine whether the character is a vowel or not. Your code should recognize both uppercase and lowercase vowels.

Lab 6 - reverse digits function

You are to complete exercise 5, p 341, writing a program which contains a user-defined function, reverseDigit. This is its header:

   int reverseDigit(int value)

This problem should seem familiar: lab 5 required you to reverse the digits of an integer as well. The difference is that in the previous program you merely had to strip off the digits of the input number one at a time, working from right to left, and print them at the command line; in this program, not only do you need to reverse the digits, you need to store the digits as an integer. You will be doing the work in your user-defined function and returning the reversed number to main.

Saturday, October 29, 2011

Exam #1 results

I have finished grading the first exam. Several students did very well prior to the application of the curve. Several students did not. The five no-shows (Fs in the table) must see me in order to make arrangements for make up exams.

Grade distribution follows:

Wednesday, October 26, 2011

Exam #1 source code

These are solutions to the programming problems from this week's exam. Please note that the methods presented are not the only way to solve the problems assigned. If you used a different approach and your code generated a valid answer, you could still earn full credit.

Exam #1 short answers

I am still in the process of grading the exams from Monday night. In the meanwhile, you might like to review the following solutions to the short answer section of the exam. I am planning to also post some source code solutions to the programming problems presented on the test.

Tuesday, October 25, 2011

Reading assignment - chapter 6

Read chapter 6, User-Defined Functions I.

Due Date
Monday, October 31st, 6:00pm

Sunday, October 23, 2011

Whitespace... it's free!

I was reviewing today's batch of source code submissions and I noticed that an awful lot of people were not making good use of their whitespace. Please observe the following rules in your code:

Thursday, October 20, 2011

Exam #1 programming problems

I strongly suggest that each student develop a C++ solution to the following problems in preparation for the coding portion of the first exam. While I do not promise that the practical part of the exam will be *exactly* the same as any one of these problems, the actual test question will at least be very similar to one or more of these practice problems.

Wednesday, October 19, 2011

Exam #1 pretest results

I reviewed Monday's pretest answers today. Looking at only the first page, the seven multiple choice questions, the class average was 51.6%. Three students tied for the highest score of 71.4%. All other scores were below 60%

Grade distribution follows:

Exam #1 pretest comments -
     part the second

These are the solutions to the last two programming problems at the end of Monday night's pretest.

Instead of responding to each student individually, I am providing the source code solutions. Please be sure to review and understand all of these solutions.

Exam #1 pretest comments -
     part the first

Quite a few students seemed to have difficulty with the questions requiring code to be written, whether on paper or in the computer. Instead of responding to each student individually, I am providing the source code solutions to the last four problems on the pretest. Questions 8 and 9 are solved here and questions 10 and 11 are in the next post.

Please be sure to review and understand all of these solutions.

Exam #1 preparation

Your first exam, on chapters 1 through 5 of the textbook, is scheduled on Monday. Keep an eye on the blog this week for test preparation suggestions. Programming problems on exams are often very similar to the end of chapter exercises.

Monday, October 17, 2011

Elaine Lapham Memorial Scholarship


The Brookdale Community College Foundation has announced that The Elaine Lapham Memorial Scholarship is available for the spring 2012 semester. The scholarship is in the amount of $500.

WebAdvisor - interval 3

Today is the end of the third WebAdvisor monitoring interval. Students with attendance issues, poor homework performance, and/or missing assignments should take this warning seriously.

Homework 3 - guess

You are to write a program that calculates a random number from 1 to 10. Ask the user to guess the number. If the user guesses correctly, display a congratulatory message. If the user displays an incorrect answer, give the user two more tries. If after three attempts the user still has not guessed the number, display a message to that effect and terminate the program.

Friday, October 14, 2011

Public service announcement #2

Notice to all students:

Though it does not affect our Comp137 class, Brookdale is NOT closed on Veterans Day. If you have Friday classes this semester, you have school on Friday, November 11th.

Newlines

It isn't necessary to write multiple cout statements when you want a line break. This code

cout << endl;
cout << "Your random # is " << num << "." << endl;
cout << endl;


could be rewritten using the newline character, \n

cout << "\nYour random # is " << num << ".\n"
     << endl;


These two code snippets generate the same output:

Homework 2 - random number -
      alternate input option

If you would like to write an enhanced version of the second homework assignment, you can read in a char (instead of an int) and you can switch on the character entered. If you apply the tolower() function to that input character, you can make your program transparently deal with case sensitivity:

c = tolower(c);

Wednesday, October 12, 2011

Brookdale 5K

Notice to all students:


The first annual Brookdale Community College 5K run/walk to raise money for scholarships for the International Center Study Abroad Program is scheduled for Sunday, October 30th at 9:00 at Thompson Park. The cost is $25, and if you register before the 14th it includes a commemorative T-shirt. All of the donations go to the program.

You can download a race application here and a sponsorship form here.

Tuesday, October 11, 2011

Quiz #1 - results

The results for this first quiz were fairly well mixed. Some students had a firm grip on the logical operators and produced complete and correct output. Some students had mostly correct output with one or two errors. Some students were able to correctly use cout to send text to the console but couldn't remember the truth tables. All in all, not unexpected results for a first quiz.

Monday, October 10, 2011

Enhanced telephone digits

Example 5-5 in the textbook (pp 241-242) asks the user to enter an uppercase character and returns the corresponding number from the telephone keypad. If you would prefer to make the code case-insensitive, you could add the following to the program in the book.

rand() and srand()

Sometimes you need to generate a random number. In C++, the easiest way to do this is to invoke the rand() function from the cmath library. This method returns a value from [0 - 32767] but you can use a little mathematical

Here are some examples and what they return:

Lab 5 - reverse digits

You are to complete exercise 2, p 300.

You will need to employ a while loop and use the modulus operator and integer division.

Lab 4 - Cartesian coordinate system

You are to complete exercise 7, p 226.

You will need to use a combination of if/else if and the logical AND operator to determine where the user's point is located in the Cartesian coordinate system.

Lab 3 - salary increases

You are to complete exercise 6, p 165.

Lab 2 - miles per gallon program

You are to finish completing exercise 20, p 27 by creating a working console application which implements the algorithm which you developed as the solution to the problem for Lab 1.

Lab 1 - miles per gallon algorithm

You are to complete exercise 20, p 27.

You need to type up the algorithm you would use to solve the problem presented.

Submit your algorithm as a text attachment to an email to me.

Due Date:
Thursday, October 13th, 8:00am

Grades

Final grades for this class will be determined according to the following criteria:
  • Test average
  • Lab assignments
  • Homework

Homework 2 - random number

You are to write a console application that generates a random number (from 1 - 10) for the user. Display a short menu to the user, informing them which input will generate a random number and which input will terminate the program. Your solution must include a do-while loop and a switch statement.

Sunday, October 9, 2011

Reading assignment - chapter 5

Read chapter 5, Control Structures II (Repetition).

Due Date
Monday, October 10th, 6:00pm

Code submission

I am using Bloodshed's Dev-C++ IDE to test your code. When you submit your homework and your labs from now on, you will need to send me your whole project, not just your .cpp file(s).

Wednesday, October 5, 2011

Just say no to "magic numbers"

It is unacceptable to use "magic numbers" in your source code. When dealing with trivial programs, using a naked number doesn't look like such a big deal (the code is short and, if well commented, the intent of the programmer is clear) but it is still a very bad habit to develop. The problem is both clearer to see and greatly magnified once the size of the code in question is larger.

Monday, October 3, 2011

Homework 1 - days in month

You are to write a program that reads in the month and year and displays for the user the number of days in that month. You must use assert to error trap the input and you must be able to determine if the year entered is a leap year.

Deliverables

All programming assignments must be submitted by emailing the c++ source code file(s) to Professor Mayo at cmayo@brookdalecc.edu.

You will be submitting source code files, not executable files. Source code files must be attachments, not pasted into the body of the email. c++ source code files must have the .cpp extension, not .txt or any other extension.

Grades

Final grades for this class will be determined according to the following criteria:
  • Test average
  • Lab assignments
  • Homework

Sunday, October 2, 2011

Line numbers

Being able to see the line numbers in your source code can come in really handy when programming. To see the line numbers in the Dev-C++ IDE, select Tools->Editor options and select the Line Numbers option on the Display tab.

Dev-C++ IDE

You can develop, compile, and run your c++ code in Bloodshed's (free!) Integrated Development Environment (IDE), Dev-C++ 5.0 (beta).

Public service announcement #1

Notice to all students:

Brookdale is NOT closed on Columbus Day. You have class on Monday, October 10th.

Reading assignment - chapter 4

Read chapter 4, Control Structures I (Selection).

Due Date
Monday, October 3rd, 6:00pm

Required textbook

The required textbook for this course is C++ Programming: From Problem Analysis to Program Design by DS Malik.

You can buy a copy at the Brookdale bookstore or try one of the Internet retailers such as Amazon.com or Barnes and Noble.

Deadlines

Missing deadlines and snow days...

Missed Exams
Departmental policy states that a student may make up one missed exam. It is not the instructor's responsibility to track down students who have missed tests; it is your responsibility to see your instructor to arrange a make up.

Main computer lab

Hours of operation for the main computer lab and where to find the lost and found...

Lab Hours
While instructors can often answer simple homework questions via email, sometimes a student needs a little additional one-on-one assistance.