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 :

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 $\mathrm{X}$ and $\mathrm{Y}$ and then follow the following instructions : REPEAT Doubling the value in the $\mathrm{X}$ column ; Halving the value in the $\mathrm{Y}$ column (ignoring fractions ); UNTIL the value in the Y column is 1 ; OUTPUT : The sum of the values in the $\mathrm{X}$ column which correspond to odd values in the $\mathrm{Y}$ column ; EXAMPLE : INPUT : $\mathrm{X}=68 ; \mathrm{Y}=97$; \begin{tabular}{|CC|} \hline $\mathbf{X}$ & $\mathbf {Y}$ \ \hline 68 & 97 \hline 136 & 48 \ \hline 272 & 24 V \hline 544 & 12 V \hline 1088 & 6 \hline 2176 & 3 \hline 4352 & 1 \hline \end{tabular) OUTPUT : $$ 68+2176+4352=6596 $$ CS.VS.914

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 Databases Questions!