COSC1315 Fundamentals of Programming

Instructor:  Prof. Richard G. Baldwin

Assignment Number:  18

Object-Based program that illustrates if-else-if.

Making certain that you comply with the General Requirements, write a C++ program that meets the following specifications:

BEGIN WRITTEN SPECIFICATIONS

This program must use Object-Based Programming Syntax.

Without making any changes to the function named doSomething below, other than to enter your name where indicated, write all of the additional code necessary to create an Object-Based program that will produce the screen output shown below.  Note that the screen output is shown for four different input values.  Your program must produce the same output for the same four input values.  This program asks the user to enter an integer value of 1, 2, or 3, and determines if the value entered by the user matches one of the requested values.  If not, the program notifies the user that the input was a bad input.


  void doSomething(){
    cout << "Put your name here" << endl;
    int temp;
    cout << "Enter 1, 2, or 3" << endl;
    cin >> temp;
    doMultipleChoice(temp);
  }//end doSomething function

Sample Program Output for four different input values.  Your program must produce the same output for the same four input values.


Put your name here
Enter 1, 2, or 3
1
Thanks for the 1

Put your name here
Enter 1, 2, or 3
2
Thanks for the 2

Put your name here
Enter 1, 2, or 3
3
Thanks for the 3

Put your name here
Enter 1, 2, or 3
4
Bad Input

END WRITTEN SPECIFICATIONS

As specified in the General Requirements, copy the above specifications, including the two lines of upper-case characters and paste the specifications into a comment block at the beginning of your source code file.

Note:  Sometimes when copying C++ source code into HTML documents (like this one) the code will become corrupted.  This is particularly true for code that involves left and right angle brackets such as in:

#include <iostream>
if(x <= y){

Although Prof. Baldwin has made an effort avoid such problems, it is possible that some corruption of source code may have occurred during the creation of these HTML documents.  If you see anything that you believe might be corrupted source code, please notify Prof. Baldwin so that he can look into the problem, correct the code if necessary, and make all of the students aware of the problem.

-end-