COSC 1315 Labs
Fundamentals of Programming

The following are the specific descriptions for all 10 lab projects.

Four Part A:
Hours Enrolled
  • In this Lab you are going to create a complete C++ program. 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. Open your template.cpp.
    3. Save your program as "lab4a.cpp".
    4. Enter the Program found on page 102, Figure 4-30 in your text.
    5. NOTE: If you start with the template, some of these changes will already be there. Make the necessary changes to show:
      1. Comments at the top of your program with your name and correct lab number.
      2. Before the statement in main
        return 0;
        The following statement
        system ("pause");
      3. All programs for this course will require a description() function. To write the description() function you will need:
        • 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 by the program enter the hours that you are enrolled this semester at ACC
    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. Save the lab lab4a.cpp
    12. Email the cpp file (with the output pasted in comments) to jscholl@austincc.edu.
Four Part B:
Hours Enrolled
  • In this Lab you are going to update lab4a.cpp. 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. Open your lab4a.cpp.
    3. Save your program as "lab4b.cpp".
    4. Create a function called int getHours()
      This requires:
      1. the prototype placed above your main function
        int getHours();
      2. the call place in place of lines 16 and 17 shown in the text
        hours = getHours();
      3. the function definition placed below the closing brace of your main function
        int getHours()
        {
           int hours;
           cout << "Hours enrolled? ";
           cin >> hours;
           return hours;
        }
    5. Select "Execute" then "Compile"
    6. Select "Execute" then "Run"
    7. When prompted by the program enter the hours that you are enrolled this semester at ACC
    8. 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.
    9. Save the file by selecting "File" then "Save".
    10. Save the lab lab4b.cpp
    11. Email the cpp file (with the output pasted in comments) to jscholl@austincc.edu.
Five:
Fat
  • In this Lab you are going to create a complete C++ program. 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 "lab5.cpp".
    4. Enter the instructions shown in Figure 5-33 on pages 148 - 149 with the following change
      Line 23 should be:
           if (totalCals > 0 && fatGrams >= 0)
    5. NOTE: If you start with the template, some of these changes will already be there. Make the necessary changes to show:
      1. Comments at the top of your program with your name and correct lab number.
      2. Before the statement in main
        return 0;
        The following statement
        system ("pause");
    6. Update the code to include three functions. (This requires a prototype, call, and function definition for each function.)
      • void description();
      • int getTotalCalories();
      • int getFatGrams();
    7. Select "Execute" then "Compile"
    8. Select "Execute" then "Run"
    9. You are to execute the program 3 times using the input specified in Figure 5-32 on page 148 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. Email the cpp file (with the output pasted in comments) to jscholl@austincc.edu.
Six:
Sales Commission
  • 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 "lab6.cpp".
    4. Enter the instructions shown in Figure 6-32 on page 193.
    5. NOTE: If you start with the template, some of these changes will already be there. Make the necessary changes to show:
      1. Comments at the top of your program with your name and correct lab number.
      2. Before the statement in main
        return 0;
        The following statement
        system ("pause");
    6. Update the code to include four functions. (This requires a prototype, call, and function definition for each function.)
      • void description();
      • int getSales();
      • double calcCommission(int sales);
        The call for calcCommission should be placed before the code shown in lines 19 - 27. That call is written:

        commission = calcCommission(sales);
        The function definition is written below the closing brace of the function definition of getSales() and is written:
        double calcCommission(int sales)
        {
           double commission;
           the code written in lines 19 to 27 of the text
           return commission;
        }
      • void displayCommission(double commission);
        The call for displayCommission should be placed before the code shown in lines 30 - 37. That call is written:
        displayCommission(commission)
        The function definition is written below the closing brace of the function definition calcCommission(); and is written:

        void displayCommission(double commission)
        {
           the code written in lines 30 - 37 of the text
        }
    7. Select "Execute" then "Compile"
    8. Select "Execute" then "Run".
    9. You are to execute the program 4 times using the input specified in Figure 6-31 on page 192 of your text book. Be sure to copy and save ALL 4 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. Email the cpp file (with the output pasted in comments) to jscholl@austincc.edu.
Seven:
Grade
  • In this Lab you are going to create a complete C++ program. 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 "lab7.cpp".
    4. NOTE: If you start with the template, some of these changes will already be there. Make the necessary changes to show:
      1. Comments at the top of your program with your name and correct lab number.
      2. Before the statement in main
        return 0;
        The following statement
        system ("pause");
    5. Create additional functions:
      • void description();
      • int getScore(string);
      • void displayGrade(int, char);
    6. Select "Execute" then "Compile"
    7. Select "Execute" then "Run".
    8. You are to execute the program 2 times using the input specified in Figure 7-47 on page 246 of your text book. Be sure to copy and save both sets of output as comments as instructed below. Be sure to copy and save ALL sets of output as comments as instructed below.
    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. 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".
    11. Email the cpp file (with the output pasted in comments) to jscholl@austincc.edu.
Nine:
Car Payment
  • In this Lab you are going to create a complete C++ program. 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 "lab9.cpp".
    4. Enter the instructions shown in Figure 9-46 on pages 353 - 354.
    5. NOTE: If you start with the template, some of these changes will already be there. Make the necessary changes to show:
      1. Comments at the top of your program with your name and correct lab number.
      2. Before the statement in main
        return 0;
        The following statement
        system ("pause");
    6. Create additional functions for description, all input, and to display payments.
    7. Select "Execute" then "Compile".
    8. Select "Execute" then "Run".
    9. You are to execute the program using the input specified in Figure 9-45 on page 352
    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. Email the cpp file (with the output pasted in comments) to jscholl@austincc.edu.
Ten:
Electricity
  • In this Lab you are going to create a complete C++ program. 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 "lab10.cpp".
    4. NOTE: If you start with the template, some of these changes will already be there. Make the necessary changes to show:
      1. Comments at the top of your program with your name and correct lab number.
      2. Before the statement in main
        return 0;
        The following statement
        system ("pause");
    5. Select "Execute" then "Compile".
    6. Select "Execute" then "Run".
    7. You are to execute the program 2 times using the input specified in Figure 10-32 on page 399 of your text book. Be sure to copy and save both sets of output as comments as instructed below.
    8. 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.
    9. 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".
    10. Email the cpp file (with the output pasted in comments) to jscholl@austincc.edu.
Eleven:
Rainfall
  • In this Lab you are going to create a complete C++ program. 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 "lab11.cpp".
    4. NOTE: If you start with the template, some of these changes will already be there. Make the necessary changes to show:
      1. Comments at the top of your program with your name and correct lab number.
      2. Before the statement in main
        return 0;
        The following statement
        system ("pause");
    5. Enter the instructions shown in Figure 11-57 on pages 469 - 470 in a file called "Lab11.cpp".
    6. Add additional functions for description(), getRainfall(), and getChoice().
    7. Select "Execute" then "Compile".
    8. Select "Execute" then "Run".
    9. You are to execute the program 2 times using the input specified in Figure 11-58 on page 471 of your text book. Be sure to copy and save both 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. Email the cpp file (with the output pasted in comments) to jscholl@austincc.edu.
Twelve:
Shipping Charges
  • In this Lab you are going to create a complete C++ program. 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 "lab12.cpp".
    4. NOTE: If you start with the template, some of these changes will already be there. Make the necessary changes to show:
      1. Comments at the top of your program with your name and correct lab number.
      2. Before the statement in main
        return 0;
        The following statement
        system ("pause");
    5. Enter the instructions shown in Figure 12-25 on page 513 in a file called "Lab12.cpp".
    6. Add additional functions for description(), getNumOrdered(), and displayCharges().
    7. Select "Execute" then "Compile".
    8. Select "Execute" then "Run".
    9. You are to execute the program 1 time using the input specified in Figure 12-26 on page 514 of your text book. Be sure to copy and save your 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. Email the cpp file (with the output pasted in comments) to jscholl@austincc.edu.
Thirteen:
Hang Man
  • In this Lab you are going to create a complete C++ program. 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 "Lab13.cpp".
    4. NOTE: If you start with the template, some of these changes will already be there. Make the necessary changes to show:
      1. Comments at the top of your program with your name and correct lab number.
      2. Before the statement in main
        return 0;
        The following statement
        system ("pause");
    5. Enter the instructions shown in Figure 13-42 on pages 564 - 566 in a file called "Lab13.cpp".
    6. Add additional functions for description(), getOrigWord()--the function getOrigWord() should include lines 19 - 27 where a loop in the function that only returns to main after a word of 5 characters has been entered, and clears the screen before returning to main, and getLetter().
    7. Select "Execute" then "Compile".
    8. Select "Execute" then "Run".
    9. You are to execute the program 2 times using the input specified in Figures 13-43 AND 13-44 on page 566 of your text book. Be sure to copy and save BOTH 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. Email the cpp file (with the output pasted in comments) to jscholl@austincc.edu.
Fourteen:
Files
  • In this Lab you are going to create a complete C++ program. 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 "lab14.cpp".
    4. NOTE: If you start with the template, some of these changes will already be there. Make the necessary changes to show:
      1. Comments at the top of your program with your name and correct lab number.
      2. Before the statement in main
        return 0;
        The following statement
        system ("pause");
    5. Enter the instructions shown in Figure 14-20 on pages 609 - 611 in a file called "Lab14.cpp".
    6. Add additional functions for description().
    7. Select "Execute" then "Compile".
    8. Select "Execute" then "Run".
    9. You are to execute the program using the input specified in Figure 14-21 on page 611 of your text book. Be sure to copy and save your 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. Email the cpp file (with the output pasted in comments) AND your sales.txt file to jscholl@austincc.edu.