Answered step by step
Verified Expert Solution
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 $\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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started