Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CSC 1 3 4 C + + PROGRAMMING _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

CSC134 C++ PROGRAMMING
_____________________________________________________________
LAB 5 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:
Chapter 7 of the lecture slides and textbook.
CSC134-Coding Guidelines.doc posted in Course Resources -> Tutorials and Guidelines to Create and Submit C++ Programs.
GRADING RUBRIC
Indent code and insert comments to document your program. [10 pts]
Program must be implemented and run as instructed. Program that does not compile and run will not receive any credit. [80 pts]
Submit the C++ programs to Blackboard correctly. [10 pts]
INSTRUCTIONS
Create an empty C++ program YourLastname_Lab5, write code to create a report using icecream flavor ratings received from the attached text file flavors.txt, which contains the customers Last name, First name, score for vanilla, score for chocolate, score for strawberry, score for banana, score for oreo.
Alfalfa Aloysius 5.06.09.08.59.5
Alfred Francis 9.09.58.29.58.5
Gerty Gramma 5.64.24.58.54.0
Android Alexis 6.06.09.59.58.5
Bumpkin Fred 2.06.87.68.55.5
Rubble Betty 4.58.05.88.07.0
Noshow Cecil 6.06.04.04.56.5
Buff Bif 7.06.67.05.57.5
Airpump Andrew 5.69.44.08.58.5
Backus Jim 9.49.09.89.09.5
The program should generate the Output Report File flavors_report.txt in the following format :
o Add a new header file Lab5.h in the Header Files folder : right-click Header Files -> Add -> New Item -> Header File (.h).
o Define a namespace icecream in the Lab5.h header file. The namespace should contain the following members:
o Define counter variables for each ice cream flavor and initialize each to 0:
o Define the enum data type rating to define customers rating:
enum rating {EXCELLENT, GOOD, OK, NOT_GOOD, BAD};
o Define the enum data type flavors to define flavors:
enum flavors {VANILLA, CHOCOLATE, STAWBERRY, BANANA, OREO};
o Define function getRating to determine customers rating according to average score:
rating getRating(double vScore, double cScore, double sScore, double bScore, double oScore);
o Value-returning function.
o Requests the four scores (vanilla, chocolate, strawberry, banana, oreo) as parameters.
o Calculates the average score.
o Based on average score, returns rating type data according to the following rules :
Average rating
9.0-10 EXCELLENT
7.0-8.9 GOOD
5.0-6.9 OK
3.0-4.9 NOT_GOOD
0-2.9 BAD
o Define function getFavoriteFlavor to determine the highest score and its corresponding flavors type:
flavors getFavoriteFlavor(double vscore, double cscore, double sscore, double bscore, double oscore);
o flavors -returning function
o Requests rating as parameter.
o Determines the highest rated flavor and return that enumerated flavors type
o Define function incrementFavoriteCounter and increment the counter for the given flavors type:
void incrementFavoriteCounter(flavors favorite);
o void-returning function
o Parameter: pass by value a flavors type.
o Increments the appropriate counter for the given flavors type
o Define function convertRateToMessage to convert a rating type to a string message.
string convertRateToMessage(rating rate, flavors favFlavor);
o Value-returning function
o Requests rating and flavors as parameter.
o Returns corresponding string rating and flavor.
o Create a source/main file that reads the flavors.txt file and calls the enumerated functions to produce the output file, flavors_report.txt containing the information shown above.
o Compress the whole project folder into a zip file YourLastname_Lab5.zip and submit it through Lab 5 link in Blackboard for credit.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions

Question

Discuss profit sharing and employee stock ownership plans (ESOPs).

Answered: 1 week ago

Question

Discuss five types of employee training.

Answered: 1 week ago

Question

Identify the four federally mandated employee benefits.

Answered: 1 week ago