4) Write a program to create a class named Auxilium with the following properties: -
Instance variables/data members:
int n
to store the number using scanner class
to count the factors of a number
boolean a
to store true if number is prime
int sum
to find the sum of the prime numbers
intc
Member methods:
Auxilium()
default constructor to initialize data members
void input()
method to input a number using scanner class
boolean prime() method that checks if the original number as well as others are
prime numbers or not. For e.g. Original number = 41 is a prime number
void check()
method to print the output - “Auxilium Number" if
the combination of all the consecutive prime numbers up to the
original number when added gives rise to the same number.
For e.g.
Original number = 41
Combination = 2 + 3 + 5 + 7 + 11 + 13
= 41
Result
= Auxilium Number
For any other prime number not producing desired result, the program prints the message-
“Not an Auxilium Number” and if the user inputs any composite number then the program
prints - "Sorry! Not Possible!”.
Write a main method to create the object of the class and call the above methods.