GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

GradePack

Description of the Program to Write Upload a .c source file…

Description of the Program to Write Upload a .c source file containing a main function that will implement the following program. Your program will implement a text-based 2-players game. The goal of the game is for each player to take turn entering a single word. The first letter of that word must be the last letter of the previous word entered by the other player. You will display an error message if this is not the case and prompt again the faulty player to re-enter a word starting with the right letter. The first player starts by entering a word starting with any letter of their choice. Players are not allowed to enter words that have been previously memorized. The program memorizes a word when it is an acceptable input from one of the player (i.e., never used before, starting with right letter). There is a limit to how many words the program can memorize, this limit is entered by the user at the beginning of the game. We will keep track of the score in the form of the length of the words-chain that is created by the two players.  As soon as one of the players has no idea, they may give up by entering the string “…” instead of a word. The game then ends and the score is displayed for the winning player. To make things easier, we will assume a few things that your program does not have to enforce: The players will always enter their word all in lower-case letters. The players’ input will always consist of a single word (e.g., “disk-drive” or “diskdrive” instead of “disk drive”) Both players will agree to a theme for the words to be chosen, before to start the game. See the example of program’s execution section below for more details about the requirements. Example of Program’s Execution (user input is in bold) Words-Chains game starting. Please agree on a theme.How many used words should I keep track of? 0How many used words should I keep track of? -5How many used words should I keep track of? 4Player 1: Enter a word (must start with any letter): oneMemorized word #1 is ‘one’The words-chain is, so far, of length 1.Player 2: Enter a word (must start with ‘e’): twoYour word starts with a ‘t’ but it should start with a ‘e’. Try again.Player 2: Enter a word (must start with ‘e’): enactedMemorized word #2 is ‘enacted’The words-chain is, so far, of length 2.Player 1: Enter a word (must start with ‘d’): threeYour word starts with a ‘t’ but it should start with a ‘d’. Try again.Player 1: Enter a word (must start with ‘d’): directoryMemorized word #3 is ‘directory’The words-chain is, so far, of length 3.Player 2: Enter a word (must start with ‘y’): yellow-stoneMemorized word #4 is ‘yellow-stone’The words-chain is, so far, of length 4.Player 1: Enter a word (must start with ‘e’): enactedThis word has already been used.Try again.Player 1: Enter a word (must start with ‘e’): yellow-stoneThis word has already been used.Try again.Player 1: Enter a word (must start with ‘e’): elaborateToo many words to rememberThe words-chain is, so far, of length 5.Player 2: Enter a word (must start with ‘e’): enactedThis word has already been used.Try again.Player 2: Enter a word (must start with ‘e’): elaborateToo many words to rememberThe words-chain is, so far, of length 6.Player 1: Enter a word (must start with ‘e’): …Player gave up. Game is over.Winner is player 2 with a words-chain of length 6.The words that were memorized during the game are:oneenacteddirectoryyellow-stone How to implement the program Decompose your program into the following functions:  int ask_user_how_many_used_words(); This function will prompt the user to enter an int value (see above) until the user entered a value that is greater than zero. It will then return that value.  char** allocate_used_words(int how_many); This function will take as parameter the number of words to remember. It will then allocate a dynamical array of pointers on characters of that size. Each of the elements of this array, which will be pointers on the words remembered, will be initialized to NULL. The address of the dynamically allocated array of pointers is then returned. bool already_used(char** used, char* w, int max); This function returns true if the string passed as parameter w is one of the words that were memorized in the dynamically allocated array of strings passed as parameter used. The parameter max tells us how many words were currently memorized in used. If the word has not been memorized, the function returns false. void remember_word(char** used, char* w, int max, int* current); This function will add the word passed as the string parameter w to the dynamically allocated array of strings passed as parameter used. To do so, it will make use of the parameter max, which is the maximum number of words that can be memorized, as well as the parameter current which is the index of next word to be memorized,HINT: use the strdup function (check its manpage) to make a copy of w in the used array of pointers. int main(void); The main function will implement most of the game, using the above-described functions, so that it executes as illustrated in the example of program’s execution section. Grading Criteria: Rubric # Pts Additional Grading Notes The program compiles without compilation errors or warnings 3 Deduct 1 point per minor compilation error (e.g., typo, forgotten semi-colon, forgotten or extra curly braces or parentheses). If the program does not compile due to too many errors or due to an error that is non-trivial to fix (see above), then the whole assignment receives zero points. The program executes without crashing at runtime 3 Deduct one point for each use case that leads the program to crash (maximum 3) The program provides sufficient comments detailing the role of each function (and its parameters / return values), as well as the role of each variable used in the code. 3 3 – Implemented according to requirements 2 – Mostly properly implemented 1 – Not properly implemented 0 – not implemented Function ask_user_how_many_used_words 3 3 – Implemented according to requirements 2 – Mostly properly implemented 1 – Not properly implemented 0 – not implemented Function allocate_used_words 3 3 – Implemented according to requirements 2 – Mostly properly implemented 1 – Not properly implemented 0 – not implemented Function already_used 3 3 – Implemented according to requirements 2 – Mostly properly implemented 1 – Not properly implemented 0 – not implemented Function remember_word 3 3 – Implemented according to requirements 2 – Mostly properly implemented 1 – Not properly implemented 0 – not implemented main function 3 3 – Implemented according to requirements 2 – Mostly properly implemented 1 – Not properly implemented 0 – not implemented Total 24  

Read Details

Description of the Program to Write Upload a .c source file…

Description of the Program to Write Upload a .c source file containing a main function that implements the following program. Two players take turns entering a positive integer between 1 and 100 inclusive. The first player may enter any number between 1 and 100. Every subsequent number entered must satisfy the following rule: The sum of the digits in the number must be equal to the sum of the digits in the previous number. Example: if the previous number is 23 (sum = 2 + 3 = 5), the next number must have a digit sum of 5 (e.g., 14, 32, 50). Players may not enter numbers that have been previously used. At the start of the game, the user specifies how many numbers the program should memorize. If this limit is reached, the program refuses to memorize additional numbers but continues validating moves. A player may give up by entering 0, which immediately ends the game. The program tracks the length of the sequence (number of valid numbers entered). The winner is the player who last successfully entered a valid number. At the end of the game, the program displays: The winning player The length of the sequence The numbers that were memorized during the game (up to the maximum specified in item #5) Sample Program Execution Number Chain with Digit-Sum Rule starting.How many numbers should I keep track of? -2How many numbers should I keep track of? 0How many numbers should I keep track of? 3Player 1: Enter a number (any number between 1 and 100): 23Memorized number #1 is 23The sequence length is now 1.Player 2: Enter a number (sum of digits must equal 5): 14Memorized number #2 is 14The sequence length is now 2.Player 1: Enter a number (sum of digits must equal 5): 32Memorized number #3 is 32The sequence length is now 3.Player 2: Enter a number (sum of digits must equal 5): 41Too many numbers to rememberThe sequence length is now 4.Player 1: Enter a number (sum of digits must equal 5): 50Your number has already been used or is invalid. Try again.Player 1: Enter a number (sum of digits must equal 5): 23This number has already been used. Try again.Player 1: Enter a number (sum of digits must equal 5): 5Memorized number #4 is 5The sequence length is now 5.Player 2: Enter a number (sum of digits must equal 5): 50Too many numbers to rememberThe sequence length is now 6.Player 1: Enter a number (sum of digits must equal 5): 0Player gave up. Game is over.Winner is player 2 with a sequence length of 6.The numbers that were memorized during the game are:231432 Functions to implement 1. int ask_user_how_many_used_numbers(void);Prompt user for the number of numbers to memorize (>0).Returns: number of numbers to memorize. 2. int* allocate_used_numbers(int how_many);Allocate array for memorized numbers, initialized to 0.Parameters: how_many — max size.Returns: pointer to array. 3. bool already_used(int* used, int n, int current);Check if n is already in used.Parameters: used — array, n — number to check, current — count stored.Returns: true if used, false otherwise. 4. void remember_number(int* used, int n, int max, int* current);Store n in used if memory allows; increment current. 5. bool is_valid_number(int prev, int n);Validate n: 1–100, and if not first number, digit sum equals previous number.Parameters: prev — previous number (0 if first), n — candidate number.Returns: true if valid, false otherwise. 6. int main(void);Implements the game loop: prompts each player for input, validates numbers, checks duplicates, handles giving up, alternates turns, tracks sequence and memory, declares winner.Returns: 0 on exit. Grading Criteria Rubric # Pts Additional Grading Notes The program compiles without compilation errors or warnings 3 Deduct 1 point per minor compilation error (e.g., typo, forgotten semi-colon, forgotten or extra curly braces or parentheses). If the program does not compile due to too many errors or due to an error that is non-trivial to fix (see above), then the whole assignment receives zero points. The program executes without crashing at runtime 3 Deduct one point for each use case that leads the program to crash (maximum 3) Function ask_user_how_many_used_numbers 3 3 – Implemented according to requirements 2 – Mostly properly implemented 1 – Not properly implemented 0 – not implemented Function allocate_used_numbers 3 3 – Implemented according to requirements 2 – Mostly properly implemented 1 – Not properly implemented 0 – not implemented Function already_used 3 3 – Implemented according to requirements 2 – Mostly properly implemented 1 – Not properly implemented 0 – not implemented Function remember_number 3 3 – Implemented according to requirements 2 – Mostly properly implemented 1 – Not properly implemented 0 – not implemented Function is_valid_number 3 3 – Implemented according to requirements 2 – Mostly properly implemented 1 – Not properly implemented 0 – not implemented main function 3 3 – Implemented according to requirements 2 – Mostly properly implemented 1 – Not properly implemented 0 – not implemented Total 24    

Read Details

Name the location the red arrow is point at 1 [1] What is th…

Name the location the red arrow is point at 1 [1] What is the general name for bones 4-9, not the individual names, the group name 2 [2] What is the general name for the bones with the #10 on them, again the group name 3 [3] What is the general name for the bones in the 11-13 position? A Middle Finger or The Bird Finger are not answer, 🙂  4 [4] 

Read Details

Name this part of the Compact Bone that #2 is pointing at in…

Name this part of the Compact Bone that #2 is pointing at in the micrograph.

Read Details

Name these 3 BORDERS of this Bone. The names depend on the h…

Name these 3 BORDERS of this Bone. The names depend on the how it fits in to the body. Keep that in mind.  Name A [A] Note: superior border was not on your study list. So the answer for A is superior border. Make sure you type it in the box for A. You are welcome! Name B [B] Name C [C] 

Read Details

On January 1, 2024 Eagle Corp. purchases $800,000 of 6% bond…

On January 1, 2024 Eagle Corp. purchases $800,000 of 6% bonds that mature in 12 years, with interest payable on June 30 and December 31 each year.  Eagle Corp. purchases all the bonds in a private placement and intends to hold the bonds until maturity.  Assuming the market rate of interest on the issue date is 8%, Eagle Corp. will purchase the bonds for $697,497.  Calculate the amount of interest revenue that Eagle Corp. would record for the December 31, 2024 interest payment. You must use the honorlock calculator to solve the problem (round to the nearest dollar).

Read Details

On April 1, 2024 Eagle Corp. purchased $60,000 of Bobcat Inc…

On April 1, 2024 Eagle Corp. purchased $60,000 of Bobcat Inc.’s 8% bonds at a purchase price of 105. At the time of purchase the market rate of interest was 6%.  Eagle Corp. whose year end is December 31, expects to hold the bonds until their maturity date 5 years from the date of purchase. Interest on the bonds will be paid every April 1 and October 1 until maturity.  What is the carrying value (amortized cost) of the bond that Eagle Corp. would report on October 1, 2024? You must use the honorlock calculator to solve the problem. (round to the nearest dollar).     Answer:  $_______

Read Details

On April 1, 2024 Eagle Corp. purchased $80,000 of Bobcat Inc…

On April 1, 2024 Eagle Corp. purchased $80,000 of Bobcat Inc.’s 6% bonds at a purchase price of 96. At the time of purchase the market rate of interest was 8%.  Eagle Corp., whose year end is December 31, expects to hold the bonds until their maturity date 5 years from the date of purchase. Interest on the bonds will be paid every April 1 and October 1 until maturity.  What is the carrying value (amortized cost) of the bond that Eagle Corp. would report on October 1, 2024? You must use the honorlock calculator to solve the problem. (round to the nearest dollar).     Answer:  $_______

Read Details

PR3:  Identify and graph polynomial functions, find and inte…

PR3:  Identify and graph polynomial functions, find and interpret information (domain, zeros and multiplicities, end behavior). The following question is optional. If you complete all parts, I will grade them as RECOVERY points on Exam 1.

Read Details

Given the function \( g(x)= \frac{3x-3}{-x+2} \). Answer the…

Given the function \( g(x)= \frac{3x-3}{-x+2} \). Answer the following. a) State the equation of the horizontal asymptote. b) State the equation of the vertical asymptote. c) Find the x-intercept and write it as an ordered pair. d) Find the y-intercept and write it as an ordered pair. e) Graph the function. Label all asymptotes and intercepts on your graph. Provide answers to (a) – (d) in the space below. Show your graph for (e) on your written work page. 

Read Details

Posts pagination

Newer posts 1 … 31,758 31,759 31,760 31,761 31,762 … 98,776 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top