Homework 3


1. Identify which of the following are legal variable names.  For those that are not legal, indicate why.

  1. theUnitedStatesNavalAcademyIsLocatedInAnnapolis
  2. average CPR     
  3. class_Of_83                
  4. averageSum
  5. 7thCompany


2.   Copy and paste the following program into the Microsoft Visual C++ and compile.  Examine the errors generated by the compiler.  For EACH error reported by the compiler, circle the line causing the error, and indicate what would need to be changed on the line in order to remove the error.  


// cents.cpp

// Convert nickels and dimes to cents.

#include <iostream>

using namespace std;


int main()


   int nickels, dimes, cents;

   nickels = 3;

   Dimes = 7;

   cents = 5 * nickels + 10 * dimes;

   cout << nickels << " nickels and ";

   cout << dimes << " dimes " << endl;

   cout << "= " << cents << " cents "

   return 0;


3. Using Microsoft Visual C++, fix each compiler error in question 2 above.   

Turn in: Printout this homework assignment and annotate with your answers to questions 1 and 2. For question 3, attach a printout of the source code for your program, and a screen capture of the window showing your program successfully compiling.  Note: to capture a screen image, click in the window you want to capture, press <Ctrl><Alt>  <Printscreen>, and paste the picture into, for example, a Word document. Consider using RAPTOR to plan out the algorithm of your program before you start with the actual code! Don't forget to turn in the answers to question 1.