Question: 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  

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!