COSC 1315 Labs
Fundamentals of Programming

The following are the specific descriptions for all 10 lab projects.
One:
Practice/
Template
  • For your first C++ Lab you are going to finish a partially completed C++ program. Then you will create a template for future programs. Please follow the steps below:
    1. Download the "Ch3Lab2.cpp" file from the assignment page to your "H" drive by right clicking on the file below then select "save file as" and specify your 'H" drive.
    2. Open the Dev C++ compiler by clicking on "Start" then "All Programs" then "Programming Tools" then "Bloodshed Dev C++" then "Dev C++"
    3. Open the partially completed program file by selecting "File" then "Open Project or File" and selecting "Ch3Lab2.cpp" from your "H" drive.
    4. Enter the C++ instructions that are shaded in Figure 3-31 on page 126 of your text book. NOTE: Do NOT delete the system("pause"); instruction from the file that you opened.
    5. Make the following modifications. All programs for this course will require a description() function. To write the description() function you will need:
      • your name and today's date in the comments at the top of the file.
      • a prototype below your directives. Place the following code after your directives:
        void description();
      • a function call to invoke the function. Place the following code inside your main() function after you have declared your variables:
        description();
      • the description() function. Place your function after you have closed your main() function block. Your description() function will describe what your program does and will be cout statements:
        void description()
        {
            cout << "place your description here" << endl;
        }
    6. Select "Execute" then "Compile"
    7. Select "Execute" then "Run"
    8. When prompted enter 100 for current weekly pay and .10 for raise rate.
    9. Copy and paste the output from the DOS window as a block comment at the end of your C++ program by right clicking on the C++, selecting "Edit" then "Mark" then highlighting all of the text. Next select "Edit" again then "Copy". Set the cursor at the end of your source file and select "Edit" then "Paste". Make sure that you put a "/*" before the output and an "*/" at the end of the comments.
    10. Save the file by selecting "File" then "Save".
    11. Print the source code with the output.
    12. Now save the lab as a new name template.cpp
    13. Change the comments to be generic.
    14. Take out the coding instructions, leaving the framework and comments.
    15. Compile and execute the code. You should not have any output.
    16. Save your template.cpp file.
    17. Print the source code . Turn in your source code for both programs.
Two:
College Cost
  • In this Lab you are going to create a complete C++ program from scratch. Please follow the steps below:
    1. Open the Dev C++ compiler by clicking on "Start" then "All Programs" then "Programming Tools" then "Bloodshed Dev C++" then "Dev C++"
    2. Either open your template.cpp or create a new source file by selecting "File" then "New" then "Source File"
    3. Save your program as "Ch4Lab2.cpp".
    4. Follow the instructions for steps 4 - 8 on pages 206 - 207 in your text book.
    5. Create three functions.
      • void description;
        The function description() is used to display a message to the user that describes what the program does.
      • string getName();
        The function getName() is used to input the name. You must write a prototype, function call, and the function definition for the function getName().
      • int getHours();
        The function getHours() is used to input the hours enrolled. You must write a prototype, function call, and the function definition for the function getHours().
    6. Before the "return 0;" instruction in the main function add the following instruction "system("pause");"
    7. Select "Execute" then "Compile" and you will be asked where to save your file. Be sure to save your file as "Ch4Lab2.cpp" to your "H" drive.
    8. Select "Execute" then "Run"
    9. When prompted by the program enter your name and the hours that you are enrolled.
    10. Copy and paste the output from the DOS window as a block comment at the end of your C++ program by right clicking on the C++, selecting "Edit" then "Mark" then highlighting all of the text. Next select "Edit" again then "Copy". Set the cursor at the end of your source file and select "Edit" then "Paste". Make sure that you put a "/*" before the output and an "*/" at the end of the comments.
    11. Be sure that you put your name and today's date in the comments at the top of the file then save the file by selecting "File" then "Save".
    12. When you have finished this lab submit your finished Ch4Lab2.cpp file.
Three:
Calories
  • Please follow the steps below:
    1. Read the problem statement for Lab 5.2 on pages 271 - 272 of your text book.
    2. Open the Dev C++ compiler by clicking on "Start" then "All Programs" then "Programming Tools" then "Bloodshed Dev C++" then "Dev C++".
    3. Either open your template.cpp or create a new source file by selecting "File" then "New" then "Source File"
    4. Save your program as "Ch5Lab2.cpp".
    5. Follow the instructions for steps 4 - 8 on page 273 in your text book.
    6. Create three functions.
      • void description;
        The function description() is used to display a message to the user that describes what the program does.
      • int getTotalCal();
        The function getTotalCal() is used to input the total calories. You must write a prototype, function call, and the function definition for the function getTotalCal().
      • int getFatGrams();
        The function getFatGrams() is used to input the fat grams. You must write a prototype, function call, and the function definition for the function getFatGrams().
    7. Before the "return 0;" instruction in the main function add the following instruction "system("pause");"
    8. Select "Execute" then "Compile" and you will be asked where to save your file. Be sure to save your file as "Ch5Lab2.cpp" to your "H" drive.
    9. Select "Execute" then "Run".
    10. You are to execute the program 5 times using the input specified in steps 10 - 14 on page 275 of your text book. Be sure to copy and save ALL 5 sets of output as comments as instructed below.
    11. Copy and paste the output from the DOS window as a block comment at the end of your C++ program by right clicking on the C++, selecting "Edit" then "Mark" then highlighting all of the text. Next select "Edit" again then "Copy". Set the cursor at the end of your source file and select "Edit" then "Paste". Make sure that you put a "/*" before the output and an "*/" at the end of the comments.
    12. Be sure that you put your name and today's date in the comments at the top of the file then save the file by selecting "File" then "Save"
    13. When you have finished this lab submit your finished Ch5Lab2.cpp file.
Four:
Sales
  • In this Lab you are going to create a complete C++ program from scratch. Please follow the steps below:
    1. Read the problem statement for Lab 6.2 on pages 337 - 339 of your text book.
    2. Open the Dev C++ compiler by clicking on "Start" then "All Programs" then "Programming Tools" then "Bloodshed Dev C++" then "Dev C++".
    3. Either open your template.cpp or create a new source file by selecting "File" then "New" then "Source File"
    4. Save your program as "Ch6Lab2.cpp".
    5. Follow the instructions for step 4 on page 340 - 341 in your text book.
    6. Create three functions.
      • void description;
        The function description() is used to display a message to the user that describes what the program does.
      • int getSales();
        The function getSales() is used to input the sales. You must write a prototype, function call, and the function definition for the function getSales().
      • void displayCommission(int sales, double commissions);
        The function displayCommission() is used to display the sales and commission for an employee. You must write a prototype, function call, and the function definition for the function displayCommission().
    7. Before the "return 0;" instruction in the main function add the following instruction "system("pause");"
    8. Select "Execute" then "Compile" and you will be asked where to save your file. Be sure to save your file as "Ch6Lab2.cpp" to your "H" drive.
    9. Select "Execute" then "Run".
    10. You are to execute the program 4 times using the input specified in steps 6 - 9 on page 341 of your text book. Be sure to copy and save ALL 4 sets of output as comments as instructed below.
    11. Copy and paste the output from the DOS window as a block comment at the end of your C++ program by right clicking on the C++, selecting "Edit" then "Mark" then highlighting all of the text. Next select "Edit" again then "Copy". Set the cursor at the end of your source file and select "Edit" then "Paste". Make sure that you put a "/*" before the output and an "*/" at the end of the comments.
    12. Be sure that you put your name and today's date in the comments at the top of the file then save the file by selecting "File" then "Save".
    13. When you have finished this lab submit your finished Ch6Lab2.cpp file.
Five:
Grade
  • In this Lab you are going to create a complete C++ program from scratch. Please follow the steps below:
    1. Read the problem statement for Lab 7.2 on pages 407 - 409 of your text book.
    2. Open the Dev C++ compiler by clicking on "Start" then "All Programs" then "Programming Tools" then "Bloodshed Dev C++" then "Dev C++".
    3. Either open your template.cpp or create a new source file by selecting "File" then "New" then "Source File"
    4. Save your program as "Ch7Lab2.cpp".
    5. Follow the instructions for step 4 on pages 409 - 410 in your text book.
    6. Before the "return 0;" instruction in the main function add the following instruction "system("pause");"
    7. Select "Execute" then "Compile" and you will be asked where to save your file. Be sure to save your file as "Ch7Lab2.cpp" to your "H" drive.
    8. Select "Execute" then "Run".
    9. You are to execute the program 3 times using the input specified in steps 6 - 8 on page 411 of your text book. Be sure to copy and save ALL 3 sets of output as comments as instructed below.
    10. Copy and paste the output from the DOS window as a block comment at the end of your C++ program by right clicking on the C++, selecting "Edit" then "Mark" then highlighting all of the text. Next select "Edit" again then "Copy". Set the cursor at the end of your source file and select "Edit" then "Paste". Make sure that you put a "/*" before the output and an "*/" at the end of the comments.
    11. Be sure that you put your name and today's date in the comments at the top of the file then save the file by selecting "File" then "Save".
    12. When you have finished this lab submit your finished Ch7Lab2.cpp file.
Six:
  • In this Lab you are going to create a complete C++ program from scratch. Please follow the steps below:
    1. Read the problem statement for Lab 9.2 on pages 524 - 527 of your text book.
    2. Open the Dev C++ compiler by clicking on "Start" then "All Programs" then "Programming Tools" then "Bloodshed Dev C++" then "Dev C++".
    3. Either open your template.cpp or create a new source file by selecting "File" then "New" then "Source File"
    4. Save your program as "Ch9Lab2.cpp".
    5. Follow the instructions for steps 3 through 5 (with my required function changes) on page 528 - 529 in your text book.
    6. Before the "return 0;" instruction in the main function add the following instruction "system("pause");"
    7. Select "Execute" then "Compile" and you will be asked where to save your file. Be sure to save your file as "Ch9Lab2.cpp" to your "H" drive.
    8. Select "Execute" then "Run".
    9. You are to execute the program using the input specified in step 5 on page 529 of your text book.
    10. Copy and paste the output from the DOS window as a block comment at the end of your C++ program by right clicking on the C++, selecting "Edit" then "Mark" then highlighting all of the text. Next select "Edit" again then "Copy". Set the cursor at the end of your source file and select "Edit" then "Paste". Make sure that you put a "/*" before the output and an "*/" at the end of the comments.
    11. Be sure that you put your name and today's date in the comments at the top of the file then save the file by selecting "File" then "Save".
    12. When you have finished this lab submit your finished Ch9Lab2.cpp file.
Seven:
Water Bill
  • In this Lab you are going to create a complete C++ program from scratch. Please follow the steps below:
    1. Read the problem statement for Lab 10.2 on pages 582 - 585 of your text book.
    2. Open the Dev C++ compiler by clicking on "Start" then "All Programs" then "Programming Tools" then "Bloodshed Dev C++" then "Dev C++".
    3. Either open your template.cpp or create a new source file by selecting "File" then "New" then "Source File"
    4. Save your program as "Ch10Lab2.cpp".
    5. Follow the instructions for step 3 on pages 585 - 587 in your text book.
    6. Before the "return 0;" instruction in the main function add the following instruction "system("pause");".
    7. Select "Execute" then "Compile" and you will be asked where to save your file. Be sure to save your file as "Ch10Lab2.cpp" to your "H" drive.
    8. Select "Execute" then "Run".
    9. You are to execute the program 1 time using the input specified in step 5 on page 587 of your text book.
    10. Copy and paste the output from the DOS window as a block comment at the end of your C++ program by right clicking on the C++, selecting "Edit" then "Mark" then highlighting all of the text. Next select "Edit" again then "Copy". Set the cursor at the end of your source file and select "Edit" then "Paste". Make sure that you put a "/*" before the output and an "*/" at the end of the comments.
    11. Be sure that you put your name and today's date in the comments at the top of the file then save the file by selecting "File" then "Save".
    12. When you have finished this lab submit your finished Ch10Lab2.cpp file.
Eight:
Rainfall
  • In this Lab you are going to create a complete C++ program from scratch. Please follow the steps below:
    1. Read the problem statement for Lab 11.2 on pages 663 - 665 of your text book.
    2. Open the Dev C++ compiler by clicking on "Start" then "All Programs" then "Programming Tools" then "Bloodshed Dev C++" then "Dev C++".
    3. Either open your template.cpp or create a new source file by selecting "File" then "New" then "Source File"
    4. Save your program as "Ch11Lab2.cpp".
    5. Follow the instructions for step 3 on pages 666 - 667 in your text book.
    6. Before the "return 0;" instruction in the main function add the following instruction "system("pause");"
    7. Select "Execute" then "Compile" and you will be asked where to save your file. Be sure to save your file as "Ch11Lab2.cpp" to your "H" drive.
    8. Select "Execute" then "Run".
    9. You are to execute the program 1 time using the input specified in steps 5 - 8 on pages 667 - 668 of your text book.
    10. Copy and paste the output from the DOS window as a block comment at the end of your C++ program by right clicking on the C++, selecting "Edit" then "Mark" then highlighting all of the text. Next select "Edit" again then "Copy". Set the cursor at the end of your source file and select "Edit" then "Paste". Make sure that you put a "/*" before the output and an "*/" at the end of the comments.
    11. Be sure that you put your name and today's date in the comments at the top of the file then save the file by selecting "File" then "Save".
    12. When you have finished this lab submit your finished Ch11Lab2.cpp file.
Nine:
Hang Man
  • In this Lab you are going to create a complete C++ program from scratch. Please follow the steps below:
    1. Read the problem statement for Lab 12.2 on pages 717 - 719 of your text book.
    2. Open the Dev C++ compiler by clicking on "Start" then "All Programs" then "Programming Tools" then "Bloodshed Dev C++" then "Dev C++".
    3. Either open your template.cpp or create a new source file by selecting "File" then "New" then "Source File"
    4. Save your program as "Ch12Lab2.cpp".
    5. Follow the instructions for step 4 on pages 719 - 722 in your text book.
    6. Before the "return 0;" instruction in the main function add the following instruction "system("pause");"
    7. Select "Execute" then "Compile" and you will be asked where to save your file. Be sure to save your file as "C12Lab2.cpp" to your "H" drive.
    8. Select "Execute" then "Run".
    9. You are to execute the program per the instructions in steps 6 - 11 on pages 722 - 723 of your text book.
    10. Copy and paste the output from the DOS window as a block comment at the end of your C++ program by right clicking on the C++, selecting "Edit" then "Mark" then highlighting all of the text. Next select "Edit" again then "Copy". Set the cursor at the end of your source file and select "Edit" then "Paste". Make sure that you put a "/*" before the output and an "*/" at the end of the comments.
    11. Be sure that you put your name and today's date in the comments at the top of the file then save the file by selecting "File" then "Save".
    12. When you have finished this lab submit your finished Ch12Lab2.cpp file.
Ten:
Files
  • In this Lab you are going to create a complete C++ program from scratch. Please follow the steps below:
    1. Read the problem statement for Lab 13.2 on pages 781 - 786 of your text book.
    2. Open the Dev C++ compiler by clicking on "Start" then "All Programs" then "Programming Tools" then "Bloodshed Dev C++" then "Dev C++".
    3. Either open your template.cpp or create a new source file by selecting "File" then "New" then "Source File"
    4. Save your program as "Ch12Lab2.cpp".
    5. Follow the instructions for step 4 on pages 793 - 796 in your text book.
    6. Before the "return 0;" instruction in the main function add the following instruction "system("pause");".
    7. Select "Execute" then "Compile" and you will be asked where to save your file. Be sure to save your file as "C13Lab2.cpp" to your "H" drive.
    8. Select "Execute" then "Run".
    9. You are to execute the program per the instructions in steps 7 - 10 on pages 796 - 797 of your text book.
    10. Copy and paste the output from the DOS window as a block comment at the end of your C++ program by right clicking on the C++, selecting "Edit" then "Mark" then highlighting all of the text. Next select "Edit" again then "Copy". Set the cursor at the end of your source file and select "Edit" then "Paste". Make sure that you put a "/*" before the output and an "*/" at the end of the comments.
    11. Be sure that you put your name and today's date in the comments at the top of the file then save the file by selecting "File" then "Save".
    12. When you have finished this lab submit your finished Ch13Lab2.cpp file AND your sales.txt file.