COSC 1315 Labs
Fundamentals of Programming

The following are the specific descriptions for all 10 lab projects.
You will need to print your name as the output as part of each program.
One:
  • 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 "I" drive and save to 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-3 on page 110 of your text book.
    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 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:
  • 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 page 158 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:
  • Please follow the steps below:
    1. Read the problem statement for Lab 5.2 on pages 197 - 198 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 199 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 pages 200 - 201 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:
  • 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 242 - 244 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 steps 4 - 8 on page 245 - 246 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 10 - 13 on pages 246 - 247 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:
  • 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 289 - 291 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 steps 4 - 10 on page 291 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 12 - 14 on pages 292 - 293 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 358 - 361 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 4 - 9 on pages 361 - 363 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 1 time using the input specified in steps 11 - 13 on page 363 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:
  • 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 397 - 399 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 steps 4 - 9 on pages 399 - 401 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 steps 11 - 12 on pages 401 - 402 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:
  • 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 448 - 450 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 steps 4 - 10 on pages 450 - 452 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 12 - 15 on pages 452 - 453 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:
  • 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 486 - 488 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 steps 4 - 8 on pages 488 - 490 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 10 - 18 on page3 490 - 491 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:
  • 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 521 - 525 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 steps 4 - 10 on pages 525 - 528 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 13 - 16 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 Ch13Lab2.cpp file AND your sales.txt file.