Create an enumerated type that has class levels as its value

Assignment Help Programming Languages
Reference no: EM131324338

Assignment

College maintains a file of credit hours completed for their students, named CREDITS.TXT. Each line of the file contains:

• the student's ID number (an 8-character string, containing 2 letters followed by 6 digits)

• the student's status (an character: U for undergraduate, G for graduate, A for alumni)

• the student's number of completed credits on each line.

Example:

CC333333 U 3

AA111111 G 36

BB222222 U 80

DD444444 U 52

CD334455 U 100

BC223344 U 10

AB112233 A 134

EE555555 G 18

DE445566 U 122

The college would like you to write a program to convert the number of completed credits for all Undergraduate students to class levels, and to make the data searchable by student ID number.

The college uses the following completed credit ranges to determine the class levels:

Credits Completed Class Level:

Under 32 Freshman

32 - 63 Sophomore

64 - 95 Junior

Over 95 Senior

Create an enumerated type that has the class levels as its values, in the order given, so that the ordinal value of FRESHMAN will be 0, and the ordinal value of SENIOR will be 3.

Program Implementation

The program will do the following:

1. Display a short description of what the program will do to the user.

2. Verify the input data file exists. If it does not exist, issue an error message and exit the program immediately.

3. Read the data from the input file. For each line of data read: If the student is an undergraduate student

• Call a function to convert the credits completed to a class level

• Store student data into two separate parallel arrays.

• (NOTE: Even if you know how, you may not use an array of records!)

The first array will hold the string-type student ID number. The second array will hold the corresponding class level of the student.

You must store the enumerated type value in the second array, not the ordinal integer value.

Since the program will only be storing data for undergraduate students, if the student is not an undergraduate student, the student ID or class level will not be saved anywhere.

The arrays will be defined to hold up to 1000 items each. You can use the same count variable for both arrays, since they will always hold the same number of items.

Your code must implement array bounds error checking.

So if the file contains too many lines of data:

• Issue an error message

• Stop reading data from the file.

• Continue the program with the 1000 records in the arrays.

NOTE: The program should not issue an error message if the file contains exactly 1000 undergraduate students - only if it contains more than 1000 undergraduate students.

4. Use the selection sort to sort both parallel arrays in descending order, based on the student ID number. Remember that strings in arrays can be compared the same way that numbers can, using the less than and greater than operators.

Example: if ( studentId[oneIndex] < studentId[anotherIndex] )

NOTE: All the sample code shown in the week-by-week and in the textbook sorted in ascending (low to high) order. You will need to modify the code so that it sorts in descending (high to low) order.

5. Write the data from the sorted arrays out into another file, SORTED.TXT. This file should store one student ID and one corresponding class level per line. Sample SORTED.TXT data file (corresponding to sample input data file):

Example

DE445566 3

DD444444 1

CD334455 3

CC333333 0

BC223344 0

BB222222 2

Note that the ordinal value of the credit rating enumerated type is stored in the data file. This enables the program to simply write the data to the file from the enumerated type field, with no conversion.

6. After sorting and storing the data, loop to display the class level for specified students, as follows:

a) First display all student ID numbers in the array (horizontally, with 5 IDs per line), so the user can see his/her choices.

b) Then prompt the user for a student ID number (or X to exit the program).

Sample Output:

Student ID numbers on file are: DE445566 DD444444 CD334455 CC333333 BC223344 BB222222 Enter ID number of student to find (or X to exit):

c) After reading the student ID entered by the user, and before the program searches for the student, the program should error check that the user entered ID number is ***** correctly (i.e. 2 letters followed by 6 digits).

NOTE: Error checking of the characters in the student ID number should be done using loops, not by using brute force to check each individual character. Remember that you can access the individual characters within a string, as if the string was an array of characters.

For example: inputIdNumber[0] could be used to access the first character in the student ID number input by the user.

The program is due Thursday. Here is some more information you may need

HINT: For each index, use the position index to determine whether the character should be a letter or digit. Then use a character function from the cctype library to check for a letter, if it should be a letter or to check for a digit if it should be a digit.

If an invalid student ID number format is entered, give a descriptive error message explaining the correct format, and re-prompt until a good student ID number is *****

Examples: Input AA3333333 is too long. ID must be exactly 8 characters long. OR Input 3A333333 letters and digits are not in the right places ID must be exactly 8 characters long, formatted as: XX######

NOTE: The letters may be entered in either upper or lowercase, but the program should uppercase them before using them to search in the next step.

d) Use the student ID number with a binary search to find the student requested. If found, display the corresponding class level (in words) for the specified student. If not found, display an appropriate error message.

Examples: The student with ID DD444444 is a sophomore. OR No student with ID WW888888 was found.

NOTES:

Again, the binary search examples in the online Content assumed an ordered array sorted in ascending order. You must modify the search for use with arrays that are sorted in descending order.

You will need to write code to convert the enumerated class level value to a string, for display.

e) Loop displaying student ID choices, asking for an ID number, and displaying the student's class level, until the user enters "X" (or "x") to exit the program, at the student ID prompt.

You will turn in a structure chart for this program, along with the code. Your structure chart should contain one rectangle for each function in your program and include all data values passed into/out of each function (see online Content section 2.6.1 through 2.6.3 for structure chart details).

Notes

1. All fixed values within the program should be defined as constants.

2. Descriptive function, constant, and variable names must be used.

3. Your program must conform to the CS362 Coding Standards specified in Content section 1.7. As such, the program must include a file header comment block at the top of the program, and each function must include a function header comment block.

4. This program should be of modular design (minimum of SIX user-defined functions that have arguments or return values), and use proper parameter passing and prototypes.

The breakdown of the code into functions must be logical, not arbitrary!

The main function should do little more than call other functions.
The other functions should each perform ONE well-defined task.

5. All code will be structured C++ code. Object-oriented programming (classes, templates, etc) will not be used.

6. Your program should be thoroughly tested, and test data files should be submitted.

is not adequately modular (i.e. contains fewer than the required number of functions)

does not include a structure chart with the submission Before attaching files to the assignment submission.

Reference no: EM131324338

Questions Cloud

Determine the price today of the option : The risk-free rate is 10 percent. Determine the price today of the option. Then construct a risk free hedge of long stock and short option.
What will be the operating income : What will be the operating income if 20,000 haircuts are performed? Show calculations to support your answer.
Find the value of the call : This call has two periods to go before expiring. Its stock pr=is 0.90. The stock pays a dividend at the end of the first period at the rate of 0.06. Find the value of the call.
Graph the total cost and average total cost : Is there a cost advantage to having only one music publisher print a given composition? Why?
Create an enumerated type that has class levels as its value : Create an enumerated type that has the class levels as its values, in the order given, so that the ordinal value of FRESHMAN will be 0, and the ordinal value of SENIOR will be 3.
Discuss the presence of influences in the painting : The work of Degas was influenced by the experiments of Impressionists, japonisme, and modernity. Discuss the presence of these influences in the painting
Determine the possible prices of the call at expiration : Determine the possible prices of the call at expiration. Find the possible prices of the call at the end of the first period.- What is the current price of the call?
Steps of the proactive method of fraud detection : Define and discuss the six steps of the Proactive Method of Fraud Detection - Include methods to gather information about a business, questions that should be asked, and examples of fraud symptoms.
Calculate the payback and discounted payback : Susan's Salt Company is evaluating a possible Rock Salt Contract. The contract runs 5 years with 23,000 tons to be delivered per year. The revenue per ton is $135 and the variable cost per ton is $105. The machinery will cost $1,490,000 and is to be ..

Reviews

Write a Review

Programming Languages Questions & Answers

  Discuss inheritance from class bicycle from other closely

Show a class hierarchy in which the class bicycle inherits from other classes, which, in turn, can aslo be inherited from yet other classes; Discuss inheritance from class bicycle from other closely related derived classes.

  Write web application that will give report of balance

Write the web application that will give a report of the balance held in a visitor's account during past several months.

  What is the value displayed on the led

In the Data1: window, right click on num1, then left click on Show Location.  The value of the initialized variables should appear in the Memory window. Cut and paste the Memory window. What is the value displayed on the LEDs after you single step th..

  Arrays have been declared with the same data type

As you know when two arrays have been declared with the same data type, one array can be assigned to the other. The assignment statement would look like this

  Write script in fedora to automate complex system task

Write a script in fedora 10 that will automate a complex system task. The task I have chose is one that will determine the processes that are consuming system resources.

  Explain the use of master pages and themes

Explain the use of Master pages and themes, create a master page with a theme of your own, the master will contain a simple welcome page and the calculator page you created from the prior week.

  Write down a program which uses for loops to prints the

a write a program that uses for loops to prints the following patterns separately one below the other. all asterisks

  Write program to prints the question

Write a program that prints the question"do you want to continue?" and reads a user input. if the user input is"y", "yes", "ok", "sure", or "why not?".

  Find the sum and difference for numbers

Write a program that prompts the user for two numbers, finds the sum and difference for those numbers and displays a descriptive label for each computation by calling two different functions. Use Function Prototypes.

  Do ides help or hinder newbies learning to code

Do IDEs help or hinder newbies learning to code? Should they first be exposed to a text editor without a lot of fancy features to learn how to set things up

  Computes the wind-chill factor for a given temperature

The user should be able to enter a temperature and wind speed via text boxes, then click a button to view the corresponding wind-chill factor in a separate text box. As part of your page, you should define a function named Wi ndChi 11 that accepts..

  Program to read information from keyboard

Write a C++ program that reads the following information from the keyboard terminated with the sentinel -999 in the Student Number, and stores the records in arrays (3 separate arrays).

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd