Question: CSC134 C++ Programming _____________________________________________________________ Lab 4: User-defined simple data types, namespaces and String type Objectives In this lab assignment, students will learn: How to create

CSC134 C++ Programming

_____________________________________________________________

Lab 4: User-defined simple data types, namespaces and String type

Objectives

In this lab assignment, students will learn:

How to create a simple data type (enumeration type)

How to use the operators with enum types

How to use the enum types in a control statement

How to write functions with enum types

How to use the namespace mechanism

COURSE PREPARATION

Read the following documents:

Create Project Programs: In Course Resources

CSC134-Coding Guidelines: In Course Resources

Textbook:

Read Chapter 7 Maliks C++ Programming 8th edition textbook.

Chapter 7 Exercise:

User-Defined Simple Data Types, Namespaces, and the string Type

Goals:

In this lab assignment, students will demonstrate the ability to:

Learn how to create User-Defined Simple Data Types, Nmespces and use the string type in C++.

Grading:

Be sure to follow the Coding Standard Guidelines. You must properly indent and comment your code. Each program is worth 50 points.

Grading rubric:

Indent code and insert comments to document your program. [5 pts]

Program must be implemented and run as instructed. [40 pts]

At a minimum, include: Source file (Lab4A.cpp) and executable (Lab4A.exe) are placed in a folder called Lab4A_YourName. The folder is zipped up into a file called (Lab4A_YourName.zip or Lab4A_YourName.zipx, or Lab4A_YourName.rar). The zipped file is submitted to Blackboard. Please use these file names exactly. [5 pts]

Use a similar format for Part B (i.e. Lab4B.cpp and Lab4B.exe, etc.). Make sure to include input files (if applicable).

Instructions:

Please read this lab exercise thoroughly, before attempting to code. It would be a good idea to use pencil and paper to organize your thoughts on how best to solve this exercise.

Part A :

Program Description:

Write a program to generate a report based on input received from a text file. Suppose the input text file student_grades.txt contains the students Last name , First name, SSN, Test1, Test2, Test3, and Test4.

i.e.

Alfalfa Aloysius 123-45-6789 90.0 100.0 83.0 49.0

Generate the output Report File student_final.txt in the following format :

LastName FirstName SSN Test1 Test2 Test3 Test4 FinalLetterGrade

i.e.

Alfalfa Aloysius 123-45-6789 90.0 100.0 83.0 49.0 C+

Last name First name SSN Test1 Test2 Test3 Test4 Final Grade

The program must be written to use the enum letter_grade :

enum letter_grade {A, A_PLUS, A_MINUS, B,B_PLUS, B_MINUS, C, C_PLUS, C_MINUS,D,D_PLUS,D_MINUS,F } ;

Use the following function prototype for deriving letter grade :

letter_grade deriveGrade(double average) ;

The average is calculated as follows : (test1 + test2 + test3 + test4)/4.0

The function deriveGrade should derive the letter_grade of the student based on the following grading scale.

Letter Grade

Percentage

GPA

A+

97%+

4.33/4.00 or 4.00/4.00

A

93%-96%

4.00/4.00

A-

90%-92%

3.67/4.00

B+

87%-89%

3.33/4.00

B

83%-86%

3.00/4.00

B-

80%-82%

2.67/4.00

C+

77%-79%

2.33/4.00

C

73%-76%

2.00/4.00

C-

70%-72%

1.67/4.00

D+

67%-69%

1.33/4.00

D

63%-66%

1.00/4.00

D-

60%-62%

0.67/4.00

F

0%-59%

0.00/4.00

Also provide the following function :

string convertToText(letter_grade grade) ; //This function converts a letter_grade type to a string type.

NOTES :

Place the namespace in a header file (i.e. grade.h)

and place both the enum type and letter_grade function in the namespace stdGrade

Part B: (String)

Program Description:

Write a word search program that searches an input data file for a word specified by the user. The program should display the number of times the word appears in the input data file. In addition, the program should count and display the number of characters in the input data file that are not vowels. Your program must do this by providing the following functions :

void processFile(ifstream inFile, string &word, int &wordCount, int &nonVowelCount) ;

void displayResult(string word, int wordCount, int nonVowelCount) ;

Both functions should be called from main(). No non-constant global variables should be used.

Test your program using the file provided paragraph.dat

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!