Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A Harshad number is a positive integer that is divisible by the sum of its digits. Write a method that checks if a number passed

image text in transcribed

A Harshad number is a positive integer that is divisible by the sum of its digits. Write a method that checks if a number passed to the method is Harshard or no. For example, 12 is divisible by 31=1+2), but 32 is not divisible by 5(+3+2). Write also a main method to check if a number entered by the user is Harshard or no. The program will give the option to the user to enter many numbers. The program stopes when the user enters a value different from y. Finally, the program should display the total of Harshad numbers found. If no harsher number if found the program displays "No Harshad number is found" Sample runi: Enter a nb:12 12 is a Harshad number Do you want to test a new number (y): Y 32 is not a Harshad number Do you want to test a new number (y): 18 is a Harshad number Do you want to test a new number (y):n We found 2 Harshad number (5) Enter anb:32 Enter anb:18 Sample run2: Enter anb:19 19 is not a Harshad number Do you want to test a new number (y): Enter a nb:25 25 is not a Harshad number Do you want to test a new number (y) :n No Harshad number is found

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions