Write a program that prompts the user to enter two integer numbers A and B. The program must check whether the sum of the numbers is equal to the second power of either A or B. In other words, A+B is equal to A Or A+B is equal to B. For example: if A=3 and B-6→ A+B is equal to A-9 if A-110 and B=11→ A+B is equal to B=121 The user is allowed to enter two numbers for 5 times maximum. When the sum is equal to the second power of either x or y, the program outputs the sum and the number of tries. It also outputs "The numbers should be positive!" when either x or y is negative. Sample Run 1: Enter two integers: 13 6 Enter two integers: 2 The numbers should be positive! Enter two integers: 1 Enter two integers: 3 12 The numbers are 3 and 6, theis sum is The number of tries is 4 Sample Run 2:

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter4: Control Structures I (selection)
Section: Chapter Questions
Problem 20PE: The cost of renting a room at a hotel is, say $100.00 per night. For special occasions, such as a...
icon
Related questions
Question
We need to use java program. I need to solve this question quickly.
Write a program that prompts the user to enter two integer numbers A and B. The program must check whether
the sum of the numbers is equal to the second power of either A or B. In other words, A+B is equal to A? Or
A+B is equal to B". For example:
if A=3 and B6→ A+B is equal to A-9
if A-110 and B=11> A+B is equal to B=121
The user is allowed to enter two numbers for 5 times maximum. When the sum is equal to the second power
of either x or y, the program outputs the sum and the number of tries. It also outputs "The numbers
should be positive!"when either x ory is negative.
Sample Run 1:
Enter twa integers: 13 6
Enter two integers: 2
The numbers should be positive!
Enter twob integers: 11 12
Enter two intecers: 3
The numbers are 3 land 6, their sum 1s9
The number of tries Es 4
Sample Run 2:
Enter two intecers: 11 110
The numbers are 11 and 110, EEeLE sun
The number
of tries is
ctivate Windows
o to Settings to activate
Page 4 / 4
P Type here to search
68°F Mostly clear
O ) ENG
Transcribed Image Text:Write a program that prompts the user to enter two integer numbers A and B. The program must check whether the sum of the numbers is equal to the second power of either A or B. In other words, A+B is equal to A? Or A+B is equal to B". For example: if A=3 and B6→ A+B is equal to A-9 if A-110 and B=11> A+B is equal to B=121 The user is allowed to enter two numbers for 5 times maximum. When the sum is equal to the second power of either x or y, the program outputs the sum and the number of tries. It also outputs "The numbers should be positive!"when either x ory is negative. Sample Run 1: Enter twa integers: 13 6 Enter two integers: 2 The numbers should be positive! Enter twob integers: 11 12 Enter two intecers: 3 The numbers are 3 land 6, their sum 1s9 The number of tries Es 4 Sample Run 2: Enter two intecers: 11 110 The numbers are 11 and 110, EEeLE sun The number of tries is ctivate Windows o to Settings to activate Page 4 / 4 P Type here to search 68°F Mostly clear O ) ENG
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Constants and Variables
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
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning