C++ programming assignment/2436PA2S21(1).docx Updated March 2, 2021 COSC 2436 S21 Updated March 2, 2021 COSC 2436 S21 Updated March 2, 2021 COSC 2436 S21 Program Set #2 Total Points: 30 Three problems...

3-4 Assignment, don't need the extra credit.


C++ programming assignment/2436PA2S21(1).docx Updated March 2, 2021 COSC 2436 S21 Updated March 2, 2021 COSC 2436 S21 Updated March 2, 2021 COSC 2436 S21 Program Set #2 Total Points: 30 Three problems must be implemented for full credit. Each section will state how many problems to implement within it. The required (starred) problem marked in the set must be implemented by everyone. See 2436 Grading Guide Sheet for additional grading/submission information. Partial credit will be given. (10 points each) Section One-Stacks/Queues/Recursion/Searching and Sorting- Choose two problems. 1. LISP, or LISt Processing, is a recursive based programming language, used in artificial intelligence processing, and involves the use of lists to process data. Every list is contained within parentheses. For example, (ADD 5 8) is simply 5 + 8, or 13. Write a program that evaluates mathematical LISP expressions. Input from the keyboard an expression involving ADD, SUB, MUL, and DIV, each of which are contained in a list. Each operation will begin with a three-letter abbreviation, followed by a single space, followed by the operands involved, also with single space separation. ADD and MUL may have 2 or more operands, while DIV and SUB will only have 2. Each individual list will have no more than one imbedded list as an operand, and only at the end of that list, but each expression may have multiple imbedded lists, as seen in the sample runs below. Assume proper formation when entered from the keyboard. Output the result of the mathematical expression. For C++ use the string class. Use a stack data structure. Refer to the sample output below. Sample Runs (2): Enter the LISP expression: (SUB 6 3) The result is: 3 Enter the LISP expression: (ADD 4 6 (MUL 4 5 (DIV 8 4))) The result is: 50 Name the program: LispParserXX.java or ListParserXX.cpp, where XX are your initials. 2. A word ladder is an ordering of a set of words such that each word is exactly one letter different from the previous word. Write a program to find the word ladder given a start word and an end word or determines if no word ladder exists within a ladder of seven words. Input the words to find from the keyboard and assume proper input. Output the shortest word ladder between words as a sequence of words (in the correct order) in all caps on separate lines along with the length of the ladder. If there is no ladder within seven words output, the word "Impossible". Finally, the program should ask if the user wants to run the program again (Check case). Use the data file provided by your instructor as your dictionary of valid words, and let the user input the file name from the keyboard. For C++ use the string class. Use a stack and/or queue data structure. Refer to the sample output below. Sample Run: Enter file name: words.txt Enter start word (all lowercase): fish Enter end word (all lowercase): mast Found ladder-4 words FISH FIST MIST MAST Run Again (Y/N): N Name the program: WordLatterXX.java or WordLatterXX.cpp, where XX are your initials. 3. In the game of Musical chairs, chairs are placed in a circle with one less chair than players. People march to the music around the circle of chairs until the music stops. Then each person sits in the chair nearest them. The one person that cannot find a chair is eliminated from the game. A chair is removed, and the game continues until there is just one person left. That person is the winner. Write a program to simulate a game of Musical chairs and determine the winner of each game played. The simulation will work as follows: · The chairs are numbered from 1 to m. · The people are numbered from 1 to m + 1. · Two integers a and b are given. The first integer a is the chair number where person #1 will sit when the music stops. When the music stops, the people begin sitting down with person #1 sitting in chair a, person #2 sitting in chair a + 1, etc., until chair b is reached. The person who would have been assigned to chair b is eliminated and the next person in line is seated in chair b. · Since the chairs are in a circle, once chair m is reached, the people begin sitting in chair #1 and continue until the rest of the people have been seated. · The people are then renumbered with the person sitting in chair #1 becoming person #1, the person in chair #2 becoming person #2, etc. · Chair number m is then removed, and the game is continued with one less chair and one less person. The first line of input from a text file, will contain a single integer n that indicates the number of games to be played. For each game there will be m + 2 lines where m is the number of chairs in the game. The first of these lines will be the integer m that indicates the number of chairs in the game. The second of these lines will have the first names of m + 1 players separated by a comma and a space. Each of the next m lines will have two integers separated by a space. The first integer a will represent the chair number where the people will begin sitting and the second number b will be the number, relative to the first chair, of the person who will not find a seat. Output to the screen each game played, properly labeled, on the following line output original players of the game, output a blank line, then output the order of the players, beginning with chair #1, each time the music stops. The winner will be the last person. Output a blank line between each game played. Let the user input the file name from the keyboard. For C++ use the string class. Use a linked list data structure. Refer to the sample output below. Sample File: 1 6 ANNE, BECKA, CHAD, DREW, ERNIE, FRANK, GEORGE 3 5 2 1 4 3 3 1 2 2 1 2 Sample Run: Enter the file name: chairs.txt Game 1: Original List: ANNE, BECKA, CHAD, DREW, ERNIE, FRANK, GEORGE FRANK GEORGE ANNE BECKA DREW ERNIE ERNIE FRANK GEORGE ANNE BECKA FRANK GEORGE BECKA ERNIE BECKA ERNIE FRANK FRANK ERNIE Winner: FRANK Name the program: MusicalChairsXX.java or MusicalChairsXX.cpp, where XX are your initials. Required Problem- Comprehensive. 4 (**). At the Texas high school championship swim meet, there are preliminary heats conducted for an event during the day to determine the 16 fastest swimmers in the meet who will swim in the championship finals and consolation finals at night. The fastest eight swimmers from the preliminary heats swim in the championship finals race and the next fastest eight swimmers swim in the consolation finals race. The remaining swimmers do not swim in the night events. In swimming, the lanes are numbered from 1 to 8 with lane 1 being on the far left and lane 8 being on the far right. The preferred lane numbers for a swimmer are in this order: 4, 5, 3, 6, 2, 7, 1, 8. By seeding the swimmers in this order, the fastest swimmers have the advantage of swimming in the smooth water in the middle of the pool and the slower swimmers must fight the wake of the faster swimmers by swimming in the outside lanes. Write a C++ program that will find the 16 fastest swimmers from the list of preliminary swimmers and print their lane assignments for the consolation finals and championship finals races. Input will be from a text file where the first line of input will contain a single integer n that indicates the number of events to be swum. For each event: · The first line will contain the name of the event. · The second line will contain a single integer m that indicates the number of swimmers in that event. · Each of the following m lines will contain: · a swimmer's first and last name separated by a space but containing no other spaces, followed by a space, · the swimmer's time in the preliminary heat in the form: mm:ss.hh where mm is the number of minutes, ss is the number of seconds, and hh is the number of hundredths of a second, but · if the swimmer's time is DQ, the swimmer was disqualified from the event and cannot swim in the consolation finals or championship finals events. Assume that there are at least 10 swimmers that will qualify for the night events and no two swimmers have the exact same time. For each event output: · Seed the swimmers into their preferred lanes based on the lane order above. · Then print the event and a space followed by CONSOLATION FINALS. · On each of the next 8 lines (or less if there are not enough swimmers): · Print the lane number, in order 1-8, followed by a period and a space, o Print the last name, a comma and a space followed by the first name of the swimmer assigned to that lane, and then another space, and finally, o Print the seed time of the swimmer as shown in the example on the next page. · Do not assign a lane to or print the name of any disqualified swimmers. · Print a blank line. · Then print the event and a space followed by CHAMPIONSHIP FINALS. · On each of the next 8 lines (or less if there are not enough swimmers): · Print the lane number, in order 1-8, followed by a period and a space, o Print the last name, a comma and a space followed by the first name of the swimmer assigned to that lane, and then another space, and finally, o Print the seed time of the swimmer as shown in the example on the next page. · Print a blank line. A blank line is optional after the last data set. Let the user input the file name from the keyboard. Use any appropriate sort as needed. Refer to the sample output below. Sample File: 1 100 M FREESTYLE 18 JAMES SMITH
Mar 09, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here