A five-digit number is said to be friendly if: the leftmost digit is divisible by 1 and
Fantastic news! We've Found the answer you've been seeking!
Question:
A five-digit number is said to be friendly if:
- the leftmost digit is divisible by 1 and
- the leftmost two digits are divisible by 2 and
- the leftmost 3 digits are divisible by 3 and
- the leftmost 4 digits are divisible by 4 and
- leftmost 5 digits (the five-digit number itself) is divisible by 5.
For example, the number 42325 is a friendly number:
- 4 is divisible by 1 and
- 42 is divisible by 2 and
- 423 is divisible by 3 and
- 4232 is divisible by 4 and
- 42325 is divisible by 5.
Write a program that will accept a 5 digit number (i.e, 10000 - 99999) from the user and prints to the screen a message telling the user if the number entered is or is not a friendly number. If the number entered is not a 5 digit number print to the screen an appropriate message and end the program. You must use an if/else statement which must have a condition constructed using boolean logic to test if the number is friendly.
Name your program Friendly_yourInitials.java where yourInitials represents yourinitials.
Related Book For
Holt McDougal Larson Geometry
ISBN: 9780547315171
1st Edition
Authors: Ron Larson, Laurie Boswell, Timothy D. Kanold, Lee Stiff
Posted Date: