Question: 1. 5.22 LAB: Word frequencies Write a program that reads a list of words. Then, the program outputs those words and their frequencies. The input

1.

1. 5.22 LAB: Word frequencies Write a program that reads a listof words. Then, the program outputs those words and their frequencies. Theinput begins with an integer indicating the number of words that follow.Assume that the list will always contain fewer than 20 words. Ex:lfthe input is: 5 hey hi Mark hi mark the output is:hey 1 hi 2 Mark 1 hi 2 mark l Hint: Use

5.22 LAB: Word frequencies Write a program that reads a list of words. Then, the program outputs those words and their frequencies. The input begins with an integer indicating the number of words that follow. Assume that the list will always contain fewer than 20 words. Ex: lfthe input is: 5 hey hi Mark hi mark the output is: hey 1 hi 2 Mark 1 hi 2 mark l Hint: Use two vectors, one vector for the strings and one vector for the frequencies. main.cpp 1 #include 2 #include #include 4 using namespace std; 5 int main() { 7 8 * Type your code here. * / 9 10 return 0; 11 1212.7 LAB: Simple integer division - multiple exception handlers Write a program that reads integers userNum and divNum as input, and output the quotient (userNum divided by divNum): Use a try block to perform the statements and throw a runtime_error exception with the message "Divide by zero!" when a division by zero happens. Use a catch block to catch any runtime_error caused by dividing by zero and output an exception message. Use another catch block to catch any ios_base::failure caused by invalid input and output an exception message. Note: ios_base::failure is thrown when a user enters a value of different data type than what is defined in the program: Do not write code to throw ios_base::failure exception in the program. Ex: If the input of the program is: 15 3 the output of the program is: 5 Ex: If the input of the program is: 10 O the output of the program is: Runtime Exception: Divide by zero! Ex: If the input of the program is: twenty 5 the output of the program is: Input Exception: basic_ios::clear: iostream error main.cpp 1 #include 2 #include 3 using namespace std; 4 int main( ) { JOU int userNum; int divNum; 8 int result; 9 cin. exceptions(ios: : failbit); // Allow cin to throw exceptions 10 11 /* Type your code here. */ 12 13 return 0; 14 3 156.26 LAB: Fibonacci sequence The Fibonacci sequence begins with O and then 1 follows All subsequent values are the sum of the previous two, for example: 0, 'l, 1,2, 3, 5, 8, 13. Complete the Fibonacci() function, which has an index, n, as parameter and returns the nth value in the sequence, Any negative index values should return -1. Ex: If the input is: .7 the output is: Fibonacci (7) is 13 Note: Use a for loop and DO NOT use recursion, main.cpp 1 #include 2 using namespace std; W int Fibonacci (int n) { /* Type your code here. */ 6 DO VOUT 10 int main() { 11 int startNum; 12 13 cin >> startNum; 14 cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!