Shrek has guessed three positive integers a, b, and c. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order their pairwise sums (three numbers) and sum of all three numbers (one number). So, there are four numbers on a board in random order: a + b, a+ c, b + c and a+b+c. You have to guess three numbers a, b, and c using given numbers. Print three guessed integers in any order. Pay attention that some given numbers a, b and c can be equal (it is also possible that a-b=c). Instruction: Create a Java program that will perform the algorithm that will solve the problem using inheritance as shown in the figure. It must satisfy the 3-sample output as shown below. Explain your codes using comments.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Shrek has guessed three positive integers a, b, and c. He keeps these numbers in secret, but he
writes down four numbers on a board in arbitrary order their pairwise sums (three numbers) and sum
of all three numbers (one number). So, there are four numbers on a board in random order: a + b, a+
c, b + c and a+b+c.
You have to guess three numbers a, b, and c using given numbers. Print three guessed integers in any
order. Pay attention that some given numbers a, b and c can be equal (it is also possible that a-b=c).
Instruction: Create a Java program that will perform the algorithm that will solve the problem using
inheritance as shown in the figure. It must satisfy the 3-sample output as shown below. Explain your codes
using comments.
Main class Creates an instance of "Number"
class and call the methods. in
Input
sequence as shown in the figure.
numl, num2, num3, num4 :int
●
Main
Input class - It contains a method in() that ask
four positive integers for the numbers
on the board in random order.
in()
obj. int()
obj.getnum()
●
Number
a,b,c: int
Number class It contains a method getnum()
that computes and displays the
positive integers a, b and c that four
numbers written on a board are values
a+b, a+c, b + c and a + b + c written
in some order. Print a, b and c in any order.
getnum()
Sample Output:
run:
Enter the four positive integers in any order:
3
6
5
4
The values of 'a', 'b', and 'c' in any order: 1 2 3
BUILD SUCCESSFUL (total time: 5 seconds)
Transcribed Image Text:Shrek has guessed three positive integers a, b, and c. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order their pairwise sums (three numbers) and sum of all three numbers (one number). So, there are four numbers on a board in random order: a + b, a+ c, b + c and a+b+c. You have to guess three numbers a, b, and c using given numbers. Print three guessed integers in any order. Pay attention that some given numbers a, b and c can be equal (it is also possible that a-b=c). Instruction: Create a Java program that will perform the algorithm that will solve the problem using inheritance as shown in the figure. It must satisfy the 3-sample output as shown below. Explain your codes using comments. Main class Creates an instance of "Number" class and call the methods. in Input sequence as shown in the figure. numl, num2, num3, num4 :int ● Main Input class - It contains a method in() that ask four positive integers for the numbers on the board in random order. in() obj. int() obj.getnum() ● Number a,b,c: int Number class It contains a method getnum() that computes and displays the positive integers a, b and c that four numbers written on a board are values a+b, a+c, b + c and a + b + c written in some order. Print a, b and c in any order. getnum() Sample Output: run: Enter the four positive integers in any order: 3 6 5 4 The values of 'a', 'b', and 'c' in any order: 1 2 3 BUILD SUCCESSFUL (total time: 5 seconds)
Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Random Class and its operations
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education