Graderpractice for programmers

Back to 254275 OOP Lab 5-10

Q6. Add toString() method

Problem

Add a new method to the Palace named toString that returns amount of the castle and principality
Template:

  public static void main(String[] args)
  {
      Scanner sc = new Scanner(System.in);
       int castle = Integer.parseInt(sc.nextLine());
       int principality = Integer.parseInt(sc.nextLine());
       Palace p = new Palace(castle,principality);
       System.out.println(p.toString());
  }
.

Examples

Input

1
1

Output

Palace of Atom has The sum of the castle and principality amount 2

Input

2
4

Output

Palace of Atom has The sum of the castle and principality amount 6

Submit your solution

java