Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer both questions using java. Chapter 2, Java Basics Page 23 (b) Write a program which reads an arbitrary integer. It then prints the

Please answer both questions using java.
image text in transcribed
Chapter 2, Java Basics Page 23 (b) Write a program which reads an arbitrary integer. It then prints the integer if it is even; otherwise it prints the number one less than the integer. For example, If 10 is read, 10 is printed because it is even, but if 9 is read, 8 is printed, since 8 is an even number one less than 9 (c) Write a program which reads an arbitrary integer. It then prints the closest number divisible by three which is equal to or greater than the original integer. For example, if 10 is read, 12 is printed, since it is the next highest integer divisible by 3. If 15 is read, then 15 is printed, since it is divisible by 3

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

Recommended Textbook for

More Books

Students also viewed these Databases questions