Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a method called showTwos that uses a while loop to create a string that show the factors of 2 in a given integer. For

Write a method called showTwos that uses a while loop to create a string that show the factors of 2 in a given integer. For example the following calls should return the strings seen below
showTwos(7)
"7 = 7"
showTwos(18)
"18 = 2 * 9"
showTwos(68)
"68 = 2 * 2 * 17"
showTwos(120)
"120 = 2 * 2 * 2 * 15"
showTwos(192)
"192 = 2 * 2 * 2 * 2 * 2 * 2 * 3"
showTwos(8)
"8 = 2 * 2 * 2 * 1"
OR (either version is fine)
"8 = 2 * 2 * 2"
You may choose to make the function just a void function that prints it out, or for a stronger case, you may have the method build a string and return the string to be printed out by the main program.
could anybody solve this question?
clear words and answer please

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_2

Step: 3

blur-text-image_3

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

Beginning ASP.NET 4.5 Databases

Authors: Sandeep Chanda, Damien Foggon

3rd Edition

1430243805, 978-1430243809

More Books

Students also viewed these Databases questions

Question

What is meant by organisational theory ?

Answered: 1 week ago

Question

What is meant by decentralisation of authority ?

Answered: 1 week ago

Question

Briefly explain the qualities of an able supervisor

Answered: 1 week ago

Question

Define policy making?

Answered: 1 week ago

Question

Define co-ordination?

Answered: 1 week ago