C++ visual studio functions and arrays

May 12th, 2015

DotaCN

Category:

Computer Science

Price: $40 USD

Question description

1.Write a
complete program that receives a single phone number from the keyboard as a
string and then passes it to a filter function (by reference). The function should ERASE all non-numeric
characters from the parameter string. As
a result, the original string variable should now contain numeric-only characters.
If the number of digits in the filtered phone number is not 7 or 10, an error
message should print.
If the number of digits is 7, the number should print in the form: xxx-xxxx
If the number of digits is 10, the number should print in the form: (xxx)
xxx-xxxx3 sample traces:
Enter a phone number: 717.774.4464
(717) 774-4464

Enter a phone number: 774 4464
774-4464

Enter a phone number: 4464
Not a valid phone number

2.(Arrays,
Searching and Sorting) Write a complete
program that receives a series of student records from the keyboard and stores
them in three parallel arrays named studentID and courseNumber and grade. All arrays are to be 100 elements. The studentID array is to be of type int and
the courseNumber and grade arrays are to be of type string.

The program should prompt for the number of records to be entered and then
receive user input on how many records are to be entered. That value should be used in an input loop to
receive the series of records and store them in the parallel arrays.

Add a function to printout
all records stored in the array. Only
print records that were input from the keyboard. Much of the arrays will be unused. Add another function to search the arrays
using a specific student ID and display the student’s ID, course number, and
grade wherever found, OR the message “<student ID> doesn’t exist in
array”

Add code in main to print
all records and prompt a user to enter a student ID and search for it in the
arrays. Test both possible outcomes.

Sample trace:

Enter the number of records to be input: 6
Enter record 1 (student ID, Course number and grade): 12 COSC175 A
Enter record 2 (student ID, Course number and grade): 15 COSC175 B
Enter record 3 (student ID, Course number and grade): 22 COSC175 C
Enter record 4 (student ID, Course number and grade): 12 ENG317 A
Enter record 5 (student ID, Course number and grade): 15 ENG317 A
Enter record 6 (student ID, Course number and grade): 12 PSYC101 A

Enter a student ID for a record search: 12
12 COSC175 A
12 ENG317 A
12 PSYC101 A

Note: If a
search had been made for 17, the message “17 doesn’t exist in array” would have
been displayed.