You are to design a fight game between Neo versus Smith. The program needs to be organized using at least three functions. The specifications are as follows: 1. The program should display your name and your major. 2. The program should first call a password function. a. Request a password, multiple characters followed by return. b. For every character entered, display * character.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Please answer in C format
### Designing a Fight Game: Neo vs. Smith

This educational task involves creating a fight game between two characters, Neo and Smith, using structured programming techniques. The program must be organized with at least three distinct functions. Here are the detailed specifications for developing the game:

1. **Display Information:**
   - The program should display your name and major.

2. **Password Function:**
   - **Request a Password:** The user must input a password, which should consist of multiple characters followed by the return key.
   - **Mask Input:** For each character entered, display an asterisk (*) character.
   - **Correct Passwords:** Accept "EGC251" or "egc251" as valid passwords.
   - **Incorrect Password Handling:**
     - If the password is incorrect, prompt the user for another attempt.
     - After a second incorrect entry, inform the user it's their final attempt.
     - After the third wrong attempt, disregard further input.

3. **Game Structure:**
   - The game comprises three rounds. At each level, calculate a new health level. After three rounds, the player with the higher health level wins.

4. **Initial Health Level:**
   - Randomly assign the initial `health_level` a value between 20.0 and 24.99.

5. **Punch Inputs:**
   - In each round, accept two sequential integer inputs for `punch_N` and `punch_S`, each between 2 and 5.

6. **Damage Calculation:**
   - Calculate damage to the opponent using the formula:
     - `damage_S = punch_N * (health_level_S * randomized(0.05 - .1))`
     - `damage_N = punch_S * (health_level_N * randomized(0.05 - .1))`

7. **Health Level Update:**
   - Update each fighter’s health using:
     - `health_S = health_S * skill - damaged_S`
     - `health_N = health_N * skill - damaged_N`
   - Note: `Skill` is a randomized float variable between 0.9 and 1.1, generated each time it's used.

8. **Knockout Condition:**
   - If a fighter's health level drops below 0.5, the fight ends by knockout.

9. **Progression:**
   - If no knockout occurs, proceed to the next round.

10. **Winner Determ
Transcribed Image Text:### Designing a Fight Game: Neo vs. Smith This educational task involves creating a fight game between two characters, Neo and Smith, using structured programming techniques. The program must be organized with at least three distinct functions. Here are the detailed specifications for developing the game: 1. **Display Information:** - The program should display your name and major. 2. **Password Function:** - **Request a Password:** The user must input a password, which should consist of multiple characters followed by the return key. - **Mask Input:** For each character entered, display an asterisk (*) character. - **Correct Passwords:** Accept "EGC251" or "egc251" as valid passwords. - **Incorrect Password Handling:** - If the password is incorrect, prompt the user for another attempt. - After a second incorrect entry, inform the user it's their final attempt. - After the third wrong attempt, disregard further input. 3. **Game Structure:** - The game comprises three rounds. At each level, calculate a new health level. After three rounds, the player with the higher health level wins. 4. **Initial Health Level:** - Randomly assign the initial `health_level` a value between 20.0 and 24.99. 5. **Punch Inputs:** - In each round, accept two sequential integer inputs for `punch_N` and `punch_S`, each between 2 and 5. 6. **Damage Calculation:** - Calculate damage to the opponent using the formula: - `damage_S = punch_N * (health_level_S * randomized(0.05 - .1))` - `damage_N = punch_S * (health_level_N * randomized(0.05 - .1))` 7. **Health Level Update:** - Update each fighter’s health using: - `health_S = health_S * skill - damaged_S` - `health_N = health_N * skill - damaged_N` - Note: `Skill` is a randomized float variable between 0.9 and 1.1, generated each time it's used. 8. **Knockout Condition:** - If a fighter's health level drops below 0.5, the fight ends by knockout. 9. **Progression:** - If no knockout occurs, proceed to the next round. 10. **Winner Determ
Expert Solution
Program Explaination
  • Declare header files <stdio.h>, <stdlib.h>, <time.h> , <termios.h>, <unistd.h> and <string.h> for input/output operations, basic libraries like memory allocation, time operations, terminal I/o interface, constants of miscellaneous symbols and string operations respectively.
  • Declare the functions to be used in the entire code.
  • Declare main method
  • Use current time to seed random number generator .
  • Declare checkPassword() function
  • Use while do condition to take user input for the password
  • Use if loop to check the correct password
  • Use while condition to check the characters in the password
  • Use if-else loop to compare the strings within the password entered and correct password already mentioned in the code
  • Declare startGame() void
  • Initialize variables for Neo and Smith’s health
  • Use for loop to store their random health values
  • Check for knockout scenarios with if condition
  • Use if else statement to check health after three rounds in no knockout condition
  • Declare generateHealth() method
  • Return random health values from 20 to 24.99 with rand() command
  • Declare startRound method after which round 1 shall be started
  • Use while loop to accept valid punches which is between 2 to 5
  • Take user input for punches
  • Calculate the damages for both Smith and Neo
  • Calculate new health values for both the users
  • Declare getRandomSkill() function
  • Generate random skill value with rand() command
  • Declare CheckKnockout() function with parameters of Neo’s and Smith’s health values
  • Use if loop to check their knockout condition
  • Declare getch() function
  • Take user input and store in file memory.
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY