0% found this document useful (0 votes)
73 views7 pages

Name: Monalisa ROY Class: Xi Section: C Roll Number: Subject: Computer Project

The document describes a Java program to check if a number is mystic or not. A mystic number is one where the sum of its digits is equal to 3. The program includes a Mystic class with methods to input a number, calculate the sum of its digits, and check if it is mystic. It also lists the variables used in each method and their purpose.

Uploaded by

monalisa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views7 pages

Name: Monalisa ROY Class: Xi Section: C Roll Number: Subject: Computer Project

The document describes a Java program to check if a number is mystic or not. A mystic number is one where the sum of its digits is equal to 3. The program includes a Mystic class with methods to input a number, calculate the sum of its digits, and check if it is mystic. It also lists the variables used in each method and their purpose.

Uploaded by

monalisa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

NAME: MONALISA.

. 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

SCOPE: public void fillNum( )


VARIABLE VARIABLE PURPOSE
NAME TYPE
num int Formal parameter; to store the
value to be assigned to n

SCOPE: public int sumOfDigits( )


VARIABLE VARIABLE PURPOSE
NAME TYPE
copy int To store a copy of n on which
the operations would be carried
out
sum int To store the sum of the digits
SCOPE: public boolean isMystic( )
VARIABLE VARIABLE PURPOSE
NAME TYPE
flag boolean To store the result after
condition checking

SCOPE: public static void main (String [] args)


VARIABLE VARIABLE PURPOSE
NAME TYPE
obj Mystic Refers to class object; used to
call instance methods
scan Scanner Refers to Scanner object used
to take keyboard input
num int To store the number inputted
by the user

SOURCE CODE:
OUTPUT:

You might also like