Assignment 2 for CSCI 201

Description:

In this assignment you are asked to do two programming assignments. Both assignments are due two weeks from the date that this assignment is given.

Programming Assignment 1:

The answers to the questions asked in this assignment my be submitted electronically, as describe below, or they may be submitted in hard copy at the start of class on the day this assignment is due. The program must be submitted electronically as described below.

Write a C++ program that prompts for two integers in the range of 1 through 10. Although we can't yet stop anyone from entering integers outside of this range, display the input values on a line after the text string: "You entered: " (don't forget the space after the colon). The dialogue should look exactly like this when the user inputs 7 followed by 9:


  Enter two integer numbers between 1 and 10: 7 9
  You entered: 7 and 9

Make sure that the objects used to store the input are int's not float's.
  1. Run the program several times entering integers in the specified range and verify that your program performs correctly.
  2. Enter the number 9999999999 (ten 9's) followed by 999999999 (nine 9's) and write down the values output after "You entered: ". Explain this output.
  3. Enter the number 9.1 (or any floating point number that you choose) followed by any number. Write down the values output after "You entered: " and explain this output.
  4. Enter the characters NG (or any other characters that you choose) followed by any number. Write down the values output after "You entered: " and explain this output.
  5. Modify your program so that main is written with an uppercase M as Main. Try to Build (i.e., compile and link) your program and note the error messages. You should see a message about an unresolved external symbol _main. Explain the messages that you see.

Programming Assignment 2:

Write a C++ program that prompts for an integer that represents the amount of change (in cents) to be handed back to a customer in the United States. The objective is to use the smallest number of coins; for example, the correct change for 50 cents would be 1 half-dollar coin as opposed to 5 dimes or 50 pennies. (Hint: Use the / and % operators to calculate the correct change.) Test your program with cents equal to 16, 91, and 83 among others. When 83 cents is input the output of your program should look exactly like:


  Enter changes in cents: 83
  The minimum coins required to return 83 cents is
  ===============================================
  Half Dollars: 1
  Quarters: 1
  Dimes: 0
  Nickels: 1
  Pennies: 3

What to turn in: