C++ visual studio functions and arrays

User Generated

Bo1415

Computer Science

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-xxxx
3 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.


User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer


Anonymous
I was having a hard time with this subject, and this was a great help.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags