Hi I'm currently in school for Computer science and I'm having problems with two of my codes, the first one pertains to the title. I have to create a program that takes only the odd digits of an input and sums them. I honestly have no idea how to approach this, this is all I have
Scanner in = new Scanner(System.in);
int a;
int b;
System.out.println("Enter a number: ");
a = in.nextInt();
while (a > 0) {
if (a.charAt(0) % 2 != 0) {
}
}
the second problem I have trouble with is write program with loops that computes the sum of all square between 1 and 100 (inclusive) This is the code i have
int i=1;
int j=0;
while (i<101){
i = (i * i);
j= (j+i);
i++;
}
System.out.println(j);
Thanks, I've been searching through this book back and forth and found no ideas.