009-002-010

The public Access Modifier

Easy

Problem Description

The public Access Modifier

In this problem, you will create a program that defines a public add method in a Calculator class, calls it from the Main class with two integers read from standard input, and displays the calculation result.

Learning Objective: Understand the meaning and usage of the public access modifier

Overview

Define a public method and verify it can be accessed from anywhere.

Specifications

  • Define public add(int a, int b) method in Calculator class
  • Read two integers a and b from standard input, one per line
  • Call add(a, b) from Main class
  • Output the result

Input Format

a
b

Output Format

Result: <sum>

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up