Dit is de vraag: http://puu.sh/1OqzS
en hier is een voorbeeldje: http://puu.sh/1OqAB
Dit is wat ik momenteel heb:
Code: Selecteer alles
import java.io.*;
public class Vermenigvuldigen {
/**
* @param args
*/
public static void main(String[] args) throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(isr);
System.out.println("Welk getal maal welk getal?");
System.out.println("\tGeef het eerste getal in: ");
int getal = Integer.parseInt(in.readLine());
System.out.println("\tGeef het tweede getal in: ");
int a = Integer.parseInt(in.readLine());
int som = 0;
do {
if (getal % 2 != 0) {
som = som + a;
}
a = a * 2;
getal = (int) (Math.floor(getal / 2));
} while (getal != 1);
System.out.println(som);
}
}