Create a structure called Hero that has the following fields: 1. string coolName 2. int health 3. int defense In the main function, create an instance of Hero called hero1. Then, continuously ask for character input: 'A' or 'S' using do-while loop. • 'A' means attack and will also ask for an integer input as damage. This integer will subtract the health of the Hero. Damage would also be negated by defense. Therefore, damage = attack - defense. . 'S' means surrender which will print "I surrender!". The program terminates once the user has surrendered or the hero has no health left. If hero has no health left, print "{coolName) has fallen." Input 1. One line containing the string coolName 2. One line containing the integer health 3. One line containing the integer defense 4. Following lines may contain a character 'A' or 'S' with 'A' followed by an integer Output Enter hero name: CodyMan Enter health: 100 Enter defense: 10 Move: A 20
Create a structure called Hero that has the following fields: 1. string coolName 2. int health 3. int defense In the main function, create an instance of Hero called hero1. Then, continuously ask for character input: 'A' or 'S' using do-while loop. • 'A' means attack and will also ask for an integer input as damage. This integer will subtract the health of the Hero. Damage would also be negated by defense. Therefore, damage = attack - defense. . 'S' means surrender which will print "I surrender!". The program terminates once the user has surrendered or the hero has no health left. If hero has no health left, print "{coolName) has fallen." Input 1. One line containing the string coolName 2. One line containing the integer health 3. One line containing the integer defense 4. Following lines may contain a character 'A' or 'S' with 'A' followed by an integer Output Enter hero name: CodyMan Enter health: 100 Enter defense: 10 Move: A 20
Chapter8: Advanced Method Concepts
Section: Chapter Questions
Problem 8RQ
Related questions
Question
Solve in C Program
Passing Structure as Parameters
See Photo below for more details
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 3 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,