/*======== Fall 2025 - CS 111 Week 11 Lab Exercise - save as lab11.cpp date: 2025-11-07 ========*/ /*--- USING pair-programming * COPY and PASTE the contents of this file into a file in the CS50 IDE named: lab11.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) * 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++ lab11.cpp -o lab11 * IF it compiles with no errors: to run: in that same CS50 terminal that is open to the folder CONTAINING this .cpp file, type: ./lab11 * When you are satisfied with its output, create an example output file by typing: ./lab11 > lab11-out.txt * Download copies of your resulting lab11.cpp and lab11-out.cpp 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, *** lab11.cpp AND lab11-out.txt *** to Canvas BEFORE you leave lab. * REMEMBER to also answer the "Week 11 Lab Exercise - Pair-Programming Peer Review Survey" in Canvas, posted along with this lab exercise, by 11:59 pm TONIGHT (Friday, November 7) ---*/ /*--- by: PUT BOTH of YOUR NAMES HERE last modified: 2025-11-07 ---*/ #include <cstdlib> #include <iostream> #include <string> #include <cmath> using namespace std; /*--- WEEK 11 LAB EXERCISE - PROBLEM 1 ---*/ /*--- The purpose of this problem is to make sure that you are familiar with the class indentation style for switch statements. LOOK over Week 11 - Lecture 1's posted example function describe_grade, showing the required class style for C++ switch statements: switch(int_or_char_or_bool_expr) { case value1: statement1; ... break; case value2: statement1; ... break; ... default: statement1; ... } The following function header and body for function lookity are syntactically correct, but their style does NOT follow class coding standards! So -- MODIFY the function below to FOLLOW the class style! (The function lookity is called in the main function below, so you can make sure it still works after you fix its style.) NOTE!! The instructor will HAPPILY check over your answer IN LAB before you submit this and let you know if your version meets class style!!! <-- just ask! ---*/ /*--- IMPROVE the FORMATTING of this WORKING function to MEET CS 111 CLASS CODING STANDARDS ---*/ string lookity(int answer){switch (answer){ case 1: return "Answer: 1"; break; case 2: return "Answer: 2"; break; case 3: return "Answer: 3"; break; case 4: return "Answer: 4"; break; default: return "Invalid answer";}} /*--- WEEK 11 LAB EXERCISE - PROBLEM 2 --- */ /*--- Consider the following chart, showing Roman numeral symbols and their corresponding values: 'I' 1 'V' 5 'X' 10 'L' 50 'C' 100 'D' 500 'M' 1000 Use the design recipe to design and write a C++ function roman_val that expects a single character, and if it is one of those above in the chart, it returns its value as shown in this chart; otherwise, it returns 0. (Note: this function is intended to be case-sensitive -- if given a lowercase version of any of the above as its argument, it should return 0 for that as well.) For FULL credit: * appropriately use a switch statement in this function. * be sure to include all of the tests needed for a function using this kind of data! ---*/ /*--- signature: purpose: tests: ---*/ /*--- WEEK 11 LAB EXERCISE - PROBLEM 3 ---*/ /*--- Consider: there are times (such as when you are converting words into pig latin) when you'd like to know if a letter is a vowel or not. For our purposes here, assume that a vowel is a, e, i, o, u, A, E, I, O, or U. Use the design recipe to design and write a C++ function is_vowel that expects a single character, and if it is a vowel (according to the list above), it returns true; otherwise, it returns false. For FULL credit: * appropriately use a switch statement in this function. * be sure to include all the tests needed for a function using this kind of data! ---*/ /*--- signature: purpose: tests: ---*/ /*--- test the functions above ---*/ int main() { cout << boolalpha; cout << "*** Making sure Problem 1's function lookity runs ***" << endl; cout << "lookity: " << lookity(3) << endl; cout << "*** Testing: roman_val ***" << endl; // copy each of roman_val's test expressions into a // cout statement to print its result // cout << () << endl; cout << "*** Testing: is_vowel ***" << endl; // copy each of is_vowel's test expressions into a // cout statement to print its result // cout << () << endl; return EXIT_SUCCESS; } /*--- Remember: once you have compiled and run these and are satisfied with them, * DOWNLOAD copies of this file lab11.cpp AND your example output file lab11-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 *** lab11.cpp AND lab11-out.txt *** to Canvas BEFORE you leave lab. * ALSO answer the "Week 11 Lab Exercise - Pair-Programming Peer Review Survey" in Canvas, posted along with this lab exercise, by 11:59 pm TONIGHT (Friday, November 7) ---*/