Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

7- Write a JAVA method to realize the following algorithm: INPUT: Two integer values x, y >=1 BODY of algorithm : Define two columns

     

7- Write a JAVA method to realize the following algorithm: INPUT: Two integer values x, y >=1 BODY of algorithm : Define two columns for the two inputs X and Y and then follow the following instructions: REPEAT Doubling the value in the X column; Halving the value in the Y column (ignoring fractions); UNTIL the value in the Y column is 1; OUTPUT: The sum of the values in the X column which correspond to odd values in the Y column; EXAMPLE: INPUT X 68; Y=97; X Y 68 97 136 48 272 24 544 12 1088 6 2176 3 4352 1 OUTPUT: 68+2176+4352 = 6596

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

Introduction to Algorithms

Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest

3rd edition

978-0262033848

More Books

Students also viewed these Programming questions

Question

What are your goals for this interview today?

Answered: 1 week ago