4. (25) Write a Java program: (25 = 4(a) + 3(b) + 4(c) + 4(d) +3(e) + 3() + 4(g)) a. Randomly generate a 3-digit integer number (a 3-digit number is a number in range [100, 999]). Store this number in variable rn. Display rn. 1|Page b. Check if rn is divisible by 5 or 11 but not both. Display message: “[rn-value] is divisible by 5 or 11 but not both" or message “[rn-value] is not divisible by 5 or 11 but not both." c. Check if rn is divisible by at least 2 of the following numbers: 3, 7, 11, 13. Display message “[rn- number] is divisible by at least 2 numbers" or “[rn-value] is not divisible by at least 2 numbers".

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 40SA
icon
Related questions
Question

in java eclipse ide can you insert the numbers in the code  please

4. (25) Write a Java program: (25 = 4(a) + 3(b) + 4(c) + 4(d) +3(e) + 3(f) + 4(g))
a. Randomly generate a 3-digit integer number (a 3-digit number is a number in range [100, 999]). Store
this number in variable rn. Display rn.
1|Page
b. Check if rn is divisible by 5 or 11 but not both. Display message: “[rn-value] is divisible by 5 or 11 but
not both" or message “[rn-value] is not divisible by 5 or 11 but not both."
c. Check if rn is divisible by at least 2 of the following numbers: 3, 7, 11, 13. Display message “[rn-
number] is divisible by at least 2 numbers" or “[rn-value] is not divisible by at least 2 numbers".
d. Calculate the square, the square root, and the cube of rn. Display the following messages:
"The square of number [rn-value] is [square-value]*
"The square root of number [rn -value] is [square-root-value]"
"The cube of number [rn -value] is [cube-value]
e. Extract digits from rn, Display these 3 digits.
f. Check if the rn is a palindrome number. Display result. (A 3-digit number is palindrome if the first digit
and the last digit are the same in this number).
g. Check if digits from 100's place to l's place in rn are sorted. The digits are sorted in a 3-digit number if:
di00 > d10 2 di or d100 < d10 < di
where d100, d10, di are digits at 100's, 10°s and l's places in rn.
Display message to show result
Transcribed Image Text:4. (25) Write a Java program: (25 = 4(a) + 3(b) + 4(c) + 4(d) +3(e) + 3(f) + 4(g)) a. Randomly generate a 3-digit integer number (a 3-digit number is a number in range [100, 999]). Store this number in variable rn. Display rn. 1|Page b. Check if rn is divisible by 5 or 11 but not both. Display message: “[rn-value] is divisible by 5 or 11 but not both" or message “[rn-value] is not divisible by 5 or 11 but not both." c. Check if rn is divisible by at least 2 of the following numbers: 3, 7, 11, 13. Display message “[rn- number] is divisible by at least 2 numbers" or “[rn-value] is not divisible by at least 2 numbers". d. Calculate the square, the square root, and the cube of rn. Display the following messages: "The square of number [rn-value] is [square-value]* "The square root of number [rn -value] is [square-root-value]" "The cube of number [rn -value] is [cube-value] e. Extract digits from rn, Display these 3 digits. f. Check if the rn is a palindrome number. Display result. (A 3-digit number is palindrome if the first digit and the last digit are the same in this number). g. Check if digits from 100's place to l's place in rn are sorted. The digits are sorted in a 3-digit number if: di00 > d10 2 di or d100 < d10 < di where d100, d10, di are digits at 100's, 10°s and l's places in rn. Display message to show result
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Returning value from Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning