Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

iN C++ please do all the requirements Introduce the program to the user - void welcome() function. Allow the user to select if they want

iN C++

please do all the requirements

Introduce the program to the user - void welcome() function.

Allow the user to select if they want to encode (create) a filename or quit the program.

Write a function char displayMenu() that displays the menu and reads the option into a char variable and returns it.

Prompt and read in from the user what they want to do today. All options must be validated in the function.

If the Encode option is selected, call the encode() function and send a char array to the function. The function should call other functions and fill this char array which should be printed in main before the menu loops again.

The encode function: This should be a void function takes 1 char array encodeFileName and does the following:

Declare appropriate local variables.

Call the readInput() function to read students names and lateFlag.

Call the readInput() function to read Student ID and filename.

Call the readTime() function to read the submitted time.

Fill the encodeFileName array based on the six pieces of information adding underscores between.

Start with the students names, if the assignment is late, put LATE in the filename and nothing otherwise, add the parsed Student ID, add the time, without the colon, and then finally add the filename.

For example: If late: smith_sue_LATE_5587_1824_prog2.c

If it is not late: smith_sue_5587_1824_prog2.c

Use strncpy() and strcat() functions -

readInput(char fName[], char lName[], bool &lateFlag) - overloaded function

This void function should take 2 char arrays and 1 bool variable by reference.

It reads the students first name, last name and if the assignment is late or not. Student last name (e.g. Smith) (char array). Student first name (e.g. Sue) (char array)

Make sure all character data for the students name is lowercase - you may write a function to convert a cstring to all lowercase.

If the assignment was late or not (e.g., Y or N) (bool var). Must do data validation for this.

Hint: Remember an overloaded function has the same function name but different types of parameters or the number of parameters are different.

readInput(char parsedID[], char fileName[]) - overloaded function

This void function should take 1 char array for the parsed 4 digit Student ID that will be returned and another char array for the filename.

The Student ID (e.g., 977-15-5587) (char array) is a local variable. Use the strncpy() function to copy from position 7 till the end of the string. strncpy(parsedID, stdID + 7, 4) will copy 4 characters from the 7th position in the stdID string to the parsedID string. Check out this example code file.

The name of the file (e.g., prog2.cpp) (char array)

readTime(char strTime[])

This is a void function that should read the time from the user as 2 integers and return one char array by reference (that is the strTime array).

The time read from the user will be in military time (e.g.. 18:24 for 6:24pm) (2 ints, one for hour and one for mins). Check out this example code file to extract the numbers and convert them to a cstring.

This function must do data validation for the numbers and the HH:MM format.

main()

Declare appropriate local variables.

In an appropriate loop call the functions and output the encoded file name.

Repeat the menu in the loop until the user chooses to quit.

main() should do nothing more than the above steps.

You may not use any temporary arrays to help you solve this problem. (But you may declare as many simple variables as you like, such as ints.) You also may not use any other data structures or complex types such as strings, or other data structures such as Vector. Use only the concepts and functions we have learned so far.

Your program must have function prototypes. Place the prototypes for your functions globally, after your #includes. All functions must be implemented after main().

Try not to have any redundant code (repeated code) in your program. That is the purpose of functions.

Print a goodbye message.

Please follow ALL the instructions to submit your file in the Criteria for Success section below.

Criteria for Success

Test your program using the following sample runs, making sure you get the same output when using the given inputs (in blue).

Make sure to test your program with different sets of data.

Welcome to my fileName encoding program!!

Please pick an option below:

(e)Encode a file name

(q)quit

>>e

This program will ask you a few questions and generate an encoded fileName based on your answers.

Enter your last name: lia

Enter your first name: alia

Was your assignment Late (y/n)? Y

Enter your Student-ID (format: 222-22-2222): 234-05-4587

Enter the file name: a01.cpp

Enter the time submitted (military time - ex: 18:24 for 6:24pm): 12:01

Your encoded file name is: lia_lia_LATE_4587_1201_a01.cpp

Please pick an option below:

(e)Encode a file name

(q)quit

>>b

Invalid option! Please try again!!

Please pick an option below:

(e)Encode a file name

(q)quit

>>q

Thank you for using my fileName generator!

Follow these Coding Construct Requirements:

Must have all the functions mentioned above.

Your program must have function prototypes. Place the prototypes for your functions globally, after your #includes. All functions must be implemented after main().

Must do data validation where appropriate and where required in the functions above.

Must read the time as 2 ints and the convert to a char array.

Print a welcome and goodbye message.

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_2

Step: 3

blur-text-image_3

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 Processing Fundamentals Design

Authors: Marion Donnie Dutton Don F. Seaman

14th Edition Globel Edition

1292107634, 978-1292107639

More Books

Students also viewed these Databases questions

Question

=+5.14. Let f (x) be n2x or 2n -n2x or 0 according as 0 5x

Answered: 1 week ago