Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Friendly Number Checker FriendlyJBjava Java import ... 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

Recommended Textbook for

Holt McDougal Larson Geometry

Authors: Ron Larson, Laurie Boswell, Timothy D. Kanold, Lee Stiff

1st Edition

0547315171, 978-0547315171

More Books

Students also viewed these Programming questions