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

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter8: Advanced Method Concepts
Section: Chapter Questions
Problem 8RQ
icon
Related questions
Question
Solve in C Program Passing Structure as Parameters See Photo below for more details
Test Cases
CE Run Tests
Constraints
Layout: Side-by-Side
Executions
O Constraint 1
Must use a do-while loop
Test Cases
Constraint 2
This code must use the instance's field/s.
O Test Case 1
Your Output
No Output
Expected Output
Enter hero name: CodyMan
Enter health: 100
Enter defense: 10
Move: A 20
CodyMan current health - 90
Move: A 50
CodyMan current health - 50
Move: A 100
CodyMan has fallen,
O Test Case 2 Hidden
✓ Saved
Transcribed Image Text:Test Cases CE Run Tests Constraints Layout: Side-by-Side Executions O Constraint 1 Must use a do-while loop Test Cases Constraint 2 This code must use the instance's field/s. O Test Case 1 Your Output No Output Expected Output Enter hero name: CodyMan Enter health: 100 Enter defense: 10 Move: A 20 CodyMan current health - 90 Move: A 50 CodyMan current health - 50 Move: A 100 CodyMan has fallen, O Test Case 2 Hidden ✓ Saved
Back to Home
2. Passing Structures as Parameters Quiz
by CodeChum Admin
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
Tim
Transcribed Image Text:Back to Home 2. Passing Structures as Parameters Quiz by CodeChum Admin 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 Tim
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
User Defined DataType
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,