Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CSC 1 3 4 C + + PROGRAMMING _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
CSC C PROGRAMMING
LAB USERDEFINED 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 of the lecture slides and textbook.
CSCCoding 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. pts
Program must be implemented and run as instructed. Program that does not compile and run will not receive any credit. pts
Submit the C programs to Blackboard correctly. pts
INSTRUCTIONS
Create an empty C program YourLastnameLab 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
Alfred Francis
Gerty Gramma
Android Alexis
Bumpkin Fred
Rubble Betty
Noshow Cecil
Buff Bif
Airpump Andrew
Backus Jim
The program should generate the Output Report File flavorsreport.txt in the following format :
o Add a new header file Labh in the Header Files folder : rightclick Header Files Add New Item Header File h
o Define a namespace icecream in the Labh header file. The namespace should contain the following members:
o Define counter variables for each ice cream flavor and initialize each to :
o Define the enum data type rating to define customers rating:
enum rating EXCELLENT GOOD, OK NOTGOOD, 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 getRatingdouble vScore, double cScore, double sScore, double bScore, double oScore;
o Valuereturning 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
EXCELLENT
GOOD
OK
NOTGOOD
BAD
o Define function getFavoriteFlavor to determine the highest score and its corresponding flavors type:
flavors getFavoriteFlavordouble 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 incrementFavoriteCounterflavors favorite;
o voidreturning 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 convertRateToMessagerating rate, flavors favFlavor;
o Valuereturning function
o Requests rating and flavors as parameter.
o Returns corresponding string rating and flavor.
o Create a sourcemain file that reads the flavors.txt file and calls the enumerated functions to produce the output file, flavorsreport.txt containing the information shown above.
o Compress the whole project folder into a zip file YourLastnameLabzip and submit it through Lab link in Blackboard for credit.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started