Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE DO THIS IN JAVA!! Program 2: Buh-RING IT! For this assignment, youre going to simulate a text-based Role-Playing Game (RPG). Design (pseudocode) and implement

PLEASE DO THIS IN JAVA!!

Program 2: Buh-RING IT! For this assignment, youre going to simulate a text-based Role-Playing Game (RPG). Design (pseudocode) and implement (source) for a program that reads in 1) the heros Hit Points (HP or health), 2) the maximum damage the hero does per attack, 3) the monsters HP and 4) the maximum monsters damage per attack. When the player attacks, it will pick a random number between 0 and up to the maximum damage the player does, and then subtract that from the monster. The same thing happens when the monster attacks the hero, but damage is to the hero. The program should display rounds and the HP of the hero and monster each round. If the hero or monster dies, it should print that this happened and should NOT continue (i.e. no extra text). To learn how to create random numbers, see the appendix.

Sample run 1:

Enter the hero's starting hit points: 50

Enter the damage the heros weapon does per strike: 20

Enter the monster's starting hit points: 40

Enter the monster's damage per strike: 15

====== ROUND 1 ======

Hero attacks for: 10

Monster has 30 HP left

Monster attacks you for: 1

You have 49 HP left

====== ROUND 2 ======

Hero attacks for: 18

Monster has 12 HP left

Monster attacks you for: 7

You have 42 HP left

====== ROUND 3 ======

Hero attacks for: 0

Monster has 12 HP left

Monster attacks you for: 14

You have 28 HP left

====== ROUND 4 ======

Hero attacks for: 18

Monster has -6 HP left

The monster dies and you earn 5 XP

Battle ends...

Sample run 2:

Enter the hero's starting hit points: 50

Enter the damage the heros weapon does per strike: 10

Enter the monster's starting hit points: 40

Enter the monster's damage per strike: 20

====== ROUND 1 ======

Hero attacks for: 1

Monster has 39 HP left

Monster attacks you for: 6

You have 44 HP left

====== ROUND 2 ======

Hero attacks for: 5

Monster has 34 HP left

Monster attacks you for: 1

You have 43 HP left

====== ROUND 3 ======

Hero attacks for: 8

Monster has 26 HP left

Monster attacks you for: 8

You have 35 HP left

====== ROUND 4 ======

Hero attacks for: 4

Monster has 22 HP left

Monster attacks you for: 5

You have 30 HP left

====== ROUND 5 ======

Hero attacks for: 7

Monster has 15 HP left

Monster attacks you for: 1

You have 29 HP left

====== ROUND 6 ======

Hero attacks for: 7

Monster has 8 HP left

Monster attacks you for: 9

You have 20 HP left

====== ROUND 7 ======

Hero attacks for: 0

Monster has 8 HP left

Monster attacks you for: 14

You have 6 HP left

====== ROUND 8 ======

Hero attacks for: 4

Monster has 4 HP left

Monster attacks you for: 11

You have -5 HP left

You are killed by the monster and lose 10 gold.

Battle ends...

Program 3: National Debt. One thing that should worry anyone is financial debt. If youre like most others, you have credit card debt, student loans and so on. Our nation has similar debts, including debt to its citizens (e.g. bonds), debt to social programs, and debt to other nations. If youd like to see where we stand, check out https://www.usdebtclock.org/. If youd like to see how we compare to other nations, check out the World Debt Clocks in the upper-left corner.

How do these debt clocks work? Its exceptionally complicated, but a lot of national debt comes from issuing Treasure Notes (e.g a 10-year Treasury Note) that currently yield 3.6% interest. Your task is to write a program that prompts the user for a national debt (expressed in billions of dollars), the interest rate, and calculate how much debt is generated per year (assuming no debt is paid off by the GDP) over a 10-year period. For example, if a country currently has 1,000 billion (i.e. a trillion) dollars of debt, it will generate 36 billion dollars of additional debt in a year. The next year, the debt of 1036 billion would generate 37.296 billion additional dollars of debt, totaling 1073.296 dollars of debt.

Sample run 1:

Enter the starting debt in billions: $1000

Enter the interest rate: 3.6

***** Year 1 *****

Debt generated this year is $36.0

Accumulated debt from interest is now $36.0

Total debt is now $1036.0 billion dollars

***** Year 2 *****

Debt generated this year is $37.295998

Accumulated debt from interest is now $73.296

Total debt is now $1073.296 billion dollars

***** Year 3 *****

Debt generated this year is $38.638657

Accumulated debt from interest is now $111.934654

Total debt is now $1111.9347 billion dollars

***** Year 4 *****

Debt generated this year is $40.029648

Accumulated debt from interest is now $151.9643

Total debt is now $1151.9644 billion dollars

***** Year 5 *****

Debt generated this year is $41.470715

Accumulated debt from interest is now $193.43501

Total debt is now $1193.435 billion dollars

***** Year 6 *****

Debt generated this year is $42.96366

Accumulated debt from interest is now $236.39868

Total debt is now $1236.3987 billion dollars

***** Year 7 *****

Debt generated this year is $44.51035

Accumulated debt from interest is now $280.90903

Total debt is now $1280.909 billion dollars

***** Year 8 *****

Debt generated this year is $46.112724

Accumulated debt from interest is now $327.02176

Total debt is now $1327.0217 billion dollars

***** Year 9 *****

Debt generated this year is $47.77278

Accumulated debt from interest is now $374.79456

Total debt is now $1374.7946 billion dollars

***** Year 10 *****

Debt generated this year is $49.492603

Accumulated debt from interest is now $424.28717

Total debt is now $1424.2871 billion dollars

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

15.1 Define employee relations and employee engagement.

Answered: 1 week ago