Answered step by step
Verified Expert Solution
Question
1 Approved Answer
a) A number is called Digits_Prime if the summation of the digit is a Prime number, otherwise it is called Not_Digit_Prime. For example, number
a) A number is called Digits_Prime if the summation of the digit is a Prime number, otherwise it is called Not_Digit_Prime. For example, number = 142 and the sum of the Digit = 1+4+2= 7, which is a Prime Number. Therefore, 142 is a Digits_Prime number. i) Let the class be named Digit_Prime_Number. Write a main class program that calculates whether the number is Digits_Prime or Not_Digit_Prime considering Object Oriented Concept. (6 marks) ii) Write three (3) data members, such as number, D_Sum and Flag in the above class that are not directly modified by the object. (5 marks) iii) Design a constructor Digit_Prime_Number() that will assign the value for number. (6 marks) iv) Create a method name Prime_Number() to calculate whether the sum of the digit is Prime or otherwise. If it is a Prime number, the method will return true using the Flag; otherwise it will return false. (8 marks)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started