guys I am back
so my question is WRITE A PROGRAM TO ACCEPT A NUMBER AND CHECK AND DISPLAY WHETHER IT IS A NIVEN NUMBER OR NOT.
(NIVEN NUMBER IS THAT NUMBER WHICH IS DIVISIBLE BY ITS SUM OF DIGITS).
EXAMPLES :
CONSIDER THE NUMBER 126
SUM OF ITS DIGITS IS 1+2+6=9 AND 126 IS DIVISIBLE BY 9.
Answers
This is the answer
Plzz mark brainliest if it helps
Answer:
import java.util.*;// Scanner class//
class Nivenno// declare class name//{
public static void main()
{
Scanner Sc=new Scanner(System.in);
System.out.println("Enter the niven number:");// initialising the niven number//
int n=Sc.nextInt();
int t=Sc.nextIInt();//copying the niven number to a variable(as a copy variable)//
t=n;
int d=0;
while(n>0)//Entry-controlled loop digit extraction//
{
d=n%10;
s=s+d;
n=n/10;
}
if(t%s==0)//to check whether it is a niven number or not
{
System.out.println("Niven number is="+t);
}
else
{
System.out.println("Not a niven number:");
}
}
Explanation:First of all I think i am priveleged enough to answer your above question.I used Scanner you can also use parameter class by not using any Scanner or Input Stream Reader class. HOPE THIS HELPS PLS MARK THIS ANSWER BRAINLIEST <<@LAZARUS>>