Professional Documents
Culture Documents
. ROY
CLASS: XI
SECTION: C
ROLL NUMBER:
SUBJECT: COMPUTER
. PROJECT
TOPIC:
JAVA
PROGRAMS
PROGRAM I:
A MYSTIC NUMBER IS A NUMBER IN WHICH THE
EVENTUAL SUM OF THE DIGITS IS EQUAL TO
THREE.
Example : 984 is a mystic number because
. 9 + 8+4 =21=2+1=3
DESIGN A CLASS TO INPUT A NUMBER AND FIND
WHETHER IT IS A MYSTIC NUMBER OR NOT.
INCLUDE THE FOLLOWING MEMBERS:
INSTANCE VARIABLES:
int n
INSTANCE METHODS:
public Mystic()-Default constructor to initialize n
to 0
public void fillNum(int num) – to assign value to n
public int sumOfDigits() – to find the sum of the
digits of the number
public boolean isMystic() – to check whether the
number is mystic or not and display appropriate
message.
Write a main method the create an object and call the
above methods accordingly.
VARIABLE LISTING:
SCOPE : public class Mystic
VARIABLE VARIABLE PURPOSE
NAME TYPE
n int To store the inputted number
SOURCE CODE:
OUTPUT: