Problem 1: Numeric input validation using strings [10 Marks] There are various problems with input validation, especially when reading numeric data types using cin. Although, cin.fail() gives us some sort of solution but still it cannot handle all scenarios, for example, 123abc is considered a valid input because 123 is read where as it an alphanumeric input.
You are required to write a program that read input as a character array/string and validate it. Table 1 shows valid and invalid input for different numeric data types.
Table 1: Numeric data types
Date type | Valid input | Invalid input |
Integers | //Only digits | 123abc |
1 | 123.123 | |
2132 | aqwe121 | |
-3121 | _12 | |
+121 | ||
Float | 12.23f | 123abc |
-12.23f | 123.123 | |
Double | 12.23 | 123abc |
-12.23 | 123.123asdasda | |
12.2f |
Note: All the invalid values which cin.fail() considers should also be invalid for the program that you write.
Problem 2: Sorting and Merging [10 Marks]
Write a program that takes 5 integer arrays (of varying sizes) as input. You have to ensure that user enter these arrays in ascending order, if user enters incorrectly display a prompt to read input in correct format. Write a C++ program to produce an array that merges elements of all arrays in descending order, but it also needs to remove duplicates.
Example:
Array A_1: {1, 3, 5, 6}
Array A_2: {1, 2, 4, 8}
Array A_3: {5, 6, 7, 8}
Array A_4: {23, 24, 94, 108}
Array A_5: {1, 2, 2, 23, 24, 67, 1234}
Merged array: {1234, 108, 94, 67, 24, 23, 8, 7, 6, 5, 4, 3, 2, 1}
Note: Final array should be created/merged in sorted order. You are not allowed to do any computation on the elements entered in the Merged array. This means that different numbers will be inserted in this array in descending order and duplication will be checked at the time of insertion.
Also, no temporary arrays are allowed.
Problem 3: Employee performance reporting [20 Marks] Write a program that calculates performance based salary of customer support representatives (CSRs) in an organization:
CSR_01, CSR_02, CSR_03, CSR_04, CSR_05, CSR_06, CSR_07
payRate = $25 + 25*(complaintsResolved by each CSR/total complaints resolved)
The program should relate the data in each array through the subscripts. For example, the number in element 0 of the hours array should be the number of hours worked by the CSR whose identification number is stored in element 0 of the csrID array. The program should do the following:
Note: Ensure all necessary input validation, for example, hours, complaintsResolved cannot be negative numbers.
Problem 4: Student record [40 Marks]
Write a program that helps a faculty member prepare his semester result and calculate grades of the students. Table 2 show a typical data that a faculty member would have towards the end of the semester for any course.
Table 2: Course data
Reg No. | Midterm (25) | QUIZZES (10) | Assignments (15) | Final Exam (50) | Final Score | Grade | |||||||||||||
Q1 | Q2 | Q3 | Q4 | Q5 | Q6 | Q7 | Q8 | Q9 | Total | A1 | A2 | A3 | A4 | Total | |||||
13 | 8 | 6 | 6 | 6 | 5 | 3 | 3 | 0 | 0 | 6 | 10 | 7 | 7 | 0 | 45 | F | |||
17 | 8 | 7 | 7 | 6 | 5 | 3 | 3 | 0 | 0 | 6 | 10 | 7 | 7 | 0 | 70 | B | |||
11 | 9 | 8 | 5 | 4 | 3 | 3 | 0 | 0 | 0 | 5 | 10 | 7 | 7 | 0 | 86 | A | |||
11 | 8 | 5 | 4 | 1 | 0 | 0 | 0 | 0 | 3 | 10 | 7 | 7 | 0 | 60 | C |
Write a program that can do the following:
DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma
Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t
Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th
1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of
1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of