Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In c++ I need this done... Description: In this week's assignment we will create a menu driven program that will test your ability to handle
In c++ I need this done...
Description: In this week's assignment we will create a menu driven program that will test your ability to handle exceptions using try/catch block, we will also explore the use of the STL library specifically Containers and Algorithms. The program will contain 3 menu items as follow: Division by Zero Exception User created custom Exception Testing Exceptions using Vectors and Search Algorithm. Requirements: 1. Create a Menu Driven Program containing the following menu options: 1: Test Division by Zero Exception 2: Test User Custom Exception 3: Test Employee ID Exception 4: Exit 2. At minimum implement the following methods: showChoices(); This method should show the menu options listed above o Make sure to validate input to not accept values outside menu options. zeroException(); o This method should take in two values entered by the user a Numerator and Denominator. o Make use of Try/catch block statement when the denominator is "zero" displaying a statement stating that an Exception has been caught and thrown. userCustomException(); o Define your own Exception using a struct called MyException. o Make use of the Custom Defined Exception and test it using your program l/sample definition of a custom exception struct MyException : public exception { //Throw your exception here employeeIDException(); o Define a long Array containing 10 employee IDs where each ID is a 9 digit ID (ex: 123456789, 111555777) etc. o Define a container "vector" and use the "push back" method to copy the users from the long Array above into the Vector. o The method should take an employee ID and make use of the "binary_search" algorithm to try and find the ID the user entered. o Use try/catch to handle exceptions as follow: . If the ID has LESS than 9 digits throw and Exception . If the ID has MORE than 9 digits throw and Exception . If the ID was NOT found throw and Exception . If the ID was found, return a message stating so. //define a long array of employee IDs long employeeIDs[SIZE] I/define a vector to hold the array IDs vector long> employeeIDsVector; 3. Use functions as you see fit to: 4. Functions must pass parameters and return values as needed. Criteria Range - Low End (Did not do or did very little effort) Range - High End (Used correctly and spent Names of the variables are meaningful and the Program comments self-document the program. Correctly coded Exceptions and handled them using Try/Catch Employee IDs are stored in a long array then copied into a vector Correctly coded all needed functions Formatted the output so it is easy to read and aligned The program executes without error and the output Sample Output: MENU 1: Test Division by Zero Exception 2: Test User Custom Exception 3: Test Employee ID Exception 4: Exit Enter your choice :1 Enter the first number (Numerator): 12.2 Enter the second number (Denominator): 12 1.01667 MENU 1: Test Division by Zero Exception 2: Test User Custom Exception 3: Test Employee ID Exception 4: Exit Enter your choice :1 Enter the first number (Numerator): 23.2 Enter the second number (Denominator): 0.1 232 MENU 1: Test Division by Zero Exception 2: Test User Custom Exception 3: Test Employee ID Exception 4: Exit Enter your choice :1 Enter the first number (Numerator): 23 Enter the second number (Denominator): 0 Exception Caught Division by zero condition is not allowed! Please try again MENU 1: Test Division by Zero Exception 2: Test User Custom Exception 3: Test Employee ID Exception 4: Exit Enter your choice :2 Exception Caught This is a custom user thrown C# Exception MENU 1: Test Division by Zero Exception 2: Test User Custom Exception 3: Test Employee ID Exception 4: Exit Enter your choice :3 Please Enter the Employee ID to search for 1234567890 Exception Caught The length of the Employee ID Entered is 18 which exceeds the maximum length of 9 characters allowed. Please try again! MENU 1: Test Division by Zero Exception 2: Test User Custom Exception 3: Test Employee ID Exception 4: Exit Enter your choice :3 Please enter the Employee ID to search for 1234567 Exception Caught The length of the Employee ID Entered is 7 which is LESS than the maximum length of 9 characters allowed. Please try again! MENU 1: Test Division by Zero Exception 2: Test User Custom Exception 3: Test Employee ID Exception 4: Exit Enter your choice :3 Please Enter the Employee ID to search for 123456789 Exception Caught The Employee ID you entered is INVALID. Please try again MENU 1: Test Division by Zero Exception 2: Test User Custom Exception 3: Test Employee ID Exception 4: Exit Enter your choice :3 Please Enter the Employee ID to search for 1234567 Exception Caught The length of the Employee ID Entered is 7 which is LESS than the maximum length of 9 characters allowed. Please try again! MENU 1: Test Division by Zero Exception 2: Test User Custom Exception 3: Test Employee ID Exception 4: Exit Enter your choice :3 Please Enter the Employee ID to search for 123456789 Exception Caught The Employee ID you entered is INVALID. Please try again MENU 1: Test Division by Zero Exception 2: Test User Custom Exception 3: Test Employee ID Exception 4: Exit Enter your choice :3 please Enter the Employee ID to search for 222222222 The Employee ID you entered was found MENU 1: Test Division by Zero Exception 2: Test User Custom Exception 3: Test Employee ID Exception 4: Exit Enter your choice : Description: In this week's assignment we will create a menu driven program that will test your ability to handle exceptions using try/catch block, we will also explore the use of the STL library specifically Containers and Algorithms. The program will contain 3 menu items as follow: Division by Zero Exception User created custom Exception Testing Exceptions using Vectors and Search Algorithm. Requirements: 1. Create a Menu Driven Program containing the following menu options: 1: Test Division by Zero Exception 2: Test User Custom Exception 3: Test Employee ID Exception 4: Exit 2. At minimum implement the following methods: showChoices(); This method should show the menu options listed above o Make sure to validate input to not accept values outside menu options. zeroException(); o This method should take in two values entered by the user a Numerator and Denominator. o Make use of Try/catch block statement when the denominator is "zero" displaying a statement stating that an Exception has been caught and thrown. userCustomException(); o Define your own Exception using a struct called MyException. o Make use of the Custom Defined Exception and test it using your program l/sample definition of a custom exception struct MyException : public exception { //Throw your exception here employeeIDException(); o Define a long Array containing 10 employee IDs where each ID is a 9 digit ID (ex: 123456789, 111555777) etc. o Define a container "vector" and use the "push back" method to copy the users from the long Array above into the Vector. o The method should take an employee ID and make use of the "binary_search" algorithm to try and find the ID the user entered. o Use try/catch to handle exceptions as follow: . If the ID has LESS than 9 digits throw and Exception . If the ID has MORE than 9 digits throw and Exception . If the ID was NOT found throw and Exception . If the ID was found, return a message stating so. //define a long array of employee IDs long employeeIDs[SIZE] I/define a vector to hold the array IDs vector long> employeeIDsVector; 3. Use functions as you see fit to: 4. Functions must pass parameters and return values as needed. Criteria Range - Low End (Did not do or did very little effort) Range - High End (Used correctly and spent Names of the variables are meaningful and the Program comments self-document the program. Correctly coded Exceptions and handled them using Try/Catch Employee IDs are stored in a long array then copied into a vector Correctly coded all needed functions Formatted the output so it is easy to read and aligned The program executes without error and the output Sample Output: MENU 1: Test Division by Zero Exception 2: Test User Custom Exception 3: Test Employee ID Exception 4: Exit Enter your choice :1 Enter the first number (Numerator): 12.2 Enter the second number (Denominator): 12 1.01667 MENU 1: Test Division by Zero Exception 2: Test User Custom Exception 3: Test Employee ID Exception 4: Exit Enter your choice :1 Enter the first number (Numerator): 23.2 Enter the second number (Denominator): 0.1 232 MENU 1: Test Division by Zero Exception 2: Test User Custom Exception 3: Test Employee ID Exception 4: Exit Enter your choice :1 Enter the first number (Numerator): 23 Enter the second number (Denominator): 0 Exception Caught Division by zero condition is not allowed! Please try again MENU 1: Test Division by Zero Exception 2: Test User Custom Exception 3: Test Employee ID Exception 4: Exit Enter your choice :2 Exception Caught This is a custom user thrown C# Exception MENU 1: Test Division by Zero Exception 2: Test User Custom Exception 3: Test Employee ID Exception 4: Exit Enter your choice :3 Please Enter the Employee ID to search for 1234567890 Exception Caught The length of the Employee ID Entered is 18 which exceeds the maximum length of 9 characters allowed. Please try again! MENU 1: Test Division by Zero Exception 2: Test User Custom Exception 3: Test Employee ID Exception 4: Exit Enter your choice :3 Please enter the Employee ID to search for 1234567 Exception Caught The length of the Employee ID Entered is 7 which is LESS than the maximum length of 9 characters allowed. Please try again! MENU 1: Test Division by Zero Exception 2: Test User Custom Exception 3: Test Employee ID Exception 4: Exit Enter your choice :3 Please Enter the Employee ID to search for 123456789 Exception Caught The Employee ID you entered is INVALID. Please try again MENU 1: Test Division by Zero Exception 2: Test User Custom Exception 3: Test Employee ID Exception 4: Exit Enter your choice :3 Please Enter the Employee ID to search for 1234567 Exception Caught The length of the Employee ID Entered is 7 which is LESS than the maximum length of 9 characters allowed. Please try again! MENU 1: Test Division by Zero Exception 2: Test User Custom Exception 3: Test Employee ID Exception 4: Exit Enter your choice :3 Please Enter the Employee ID to search for 123456789 Exception Caught The Employee ID you entered is INVALID. Please try again MENU 1: Test Division by Zero Exception 2: Test User Custom Exception 3: Test Employee ID Exception 4: Exit Enter your choice :3 please Enter the Employee ID to search for 222222222 The Employee ID you entered was found MENU 1: Test Division by Zero Exception 2: Test User Custom Exception 3: Test Employee ID Exception 4: Exit Enter your choice
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started