/*======== Fall 2026 - CS 111 Week 9 Lab Exercise - save as lab9.cpp date: 2026-10-23 ========*/ /*--- NOTE: * To receive credit for this lab exercise, you must: * be present during your lab section, either in BSS 313 or in the lab Zoom session, based on your lab section * participate appropriately in a pair, either in BSS 313 or in a Zoom breakout room * You are required to use the CS50 IDE for this exercise. ---*/ /*--- USING pair-programming * COPY and PASTE the contents of this file into a file in the CS50 IDE named: lab9.cpp * ADD the parts asked for below *to* this file as specified (one student saying what to type, the other student typing it into the CS50 IDE) ******** * DO NOT DELETE THE COMMENTS! They speed up grading! ******** * remember: it is a class style standard to put a ; BLANK LINE between each comment-block and ; statement following it * also be sure to follow the C++ indentation style standards discussed in class * each time you want to compile: in a CS50 Terminal that is open to the folder CONTAINING this .cpp file, ("Open in Integrated Terminal"), type: g++ lab9.cpp -o lab9 * IF it compiles with no errors: to run: in that same CS50 Terminal that is open to the folder CONTAINING this .cpp file, type: ./lab9 * When you are satisfied with its output, create an example output file by typing: ./lab9 > lab9-out.txt * Download copies of your resulting lab9.cpp AND lab9-out.txt by right-clicking on their names in the file explorer on the left of the CS50 IDE, and use Gmail to MAIL a copy of these files to BOTH of you. * And, EACH of you should SUBMIT these TWO files, *** lab9.cpp AND lab9-out.txt *** to Canvas BEFORE you leave lab. * REMEMBER to also answer the "Week 9 Lab Exercise - Pair-Programming Peer Review Survey" in Canvas, posted along with this lab exercise, by 11:59 pm TONIGHT (Friday, October 23) ---*/ /*--- by: PUT BOTH of YOUR NAMES HERE last modified: 2026-10-23 ---*/ #include <cstdlib> #include <iostream> #include <string> #include <cmath> using namespace std; /*--- WEEK 9 LAB EXERCISE - PROBLEM 1 - function box_volume ---*/ /*--- In Week 9 Lectures 1 and 2, we used the design recipe to design and write some C++ functions. Use the design recipe to design and write a C++ function box_volume that expects a rectangular box's length and width and height and returns its volume. * BEFORE completing the function's body, include its test bool expressions in a comment AFTER the purpose statement * later, copy each test bool expression into a cout statement in the main function to actually run each test expression and see its result * (IF you want: in the main function, you can also include one or more cout statements that include JUST example call(s) of box_volume AFTER its tests, so you can SEE the value those call(s) return) ---*/ /*--- signature: purpose: tests: ---*/ /*--- WEEK 9 LAB EXERCISE - PROBLEM 2 - function cool_enough ---*/ /*--- Use the design recipe to design and write a C++ function cool_enough that expects a temperature in Fahrenheit and returns if it is less than 70 degrees Fahrenheit (true if it is, false if not) * BEFORE completing the function's body, include its test bool expressions in a comment AFTER the purpose statement * be careful -- at least how many tests are needed for this function? * later, copy each test bool expression into a cout statement in the main function to actually run each test expression and see its result * (IF you want: in the main function, you can also include one or more cout statements that include JUST example call(s) of cool_enough AFTER its tests, so you can SEE the value those call(s) return) ---*/ /*--- signature: purpose: tests: ---*/ /*--- WEEK 9 LAB EXERCISE - PROBLEM 3 - function short_name ---*/ /*--- Use the design recipe to design and write a C++ function short_name that expects a first name and a last name, and returns a shorter version of that full name made up of the first initial (the first letter of the first name), a period, a blank, and the last name. For example, short_name("Charlie", "Brown") would return "C. Brown". * (IF you want: in the main function, you can also include one or more cout statements that JUST include an example call of short_name AFTER its tests, so you can SEE the value those call(s) return) ---*/ /*--- signature: purpose: tests: ---*/ /*--- test the functions above ---*/ int main() { cout << boolalpha; cout << "*** Testing: box_volume ***" << endl; // copy each of box_volume's test bool expressions into a // cout statement to print its result // (then REMOVE the // comment parts so you can RUN that cout!) // cout << () << endl; // cout << () << endl; cout << "*** Testing: cool_enough ***" << endl; // copy each of cool_enough's test bool expressions into a // cout statement to print its result // (then REMOVE the // comment parts so you can RUN that cout!) // cout << () << endl; // cout << () << endl; // cout << () << endl; cout << "*** Testing: short_name ***" << endl; // copy each of short_name's test bool expressions into a // cout statement to print its result // (then REMOVE the // comment parts so you can RUN that cout!) // cout << () << endl; // cout << () << endl; return EXIT_SUCCESS; } /*--- Remember: once you have compiled and run these and are satisfied with them, * DOWNLOAD copies of this file lab9.cpp AND your example output file lab9-out.txt, and use Gmail to E-MAIL copies of BOTH of these files to BOTH of you. * BOTH of you should submit your files *** lab9.cpp AND lab9-out.txt *** to Canvas BEFORE you leave lab. * ALSO answer the "Week 9 Lab Exercise - Pair-Programming Peer Review Survey" in Canvas, posted along with this lab exercise, by 11:59 pm TONIGHT (Friday, October 23) ---*/