I have tried everything I can think of but nothing is working for this problem...
Prompt the user to enter an integer n.
- If
nis odd, then compute the following jump-factorial:1*3*5*7*…*n; - If
nis even, compute the following jump-factorial:2*4*6*…*n; - if
nis negative or zero, the result is0.
Finally, output the result.
import java.util.Scanner;
public class problem10 {
public static void main(String[] args) {
// part 1: open scanner
Scanner sc = new Scanner(System.in);
// part 2: prompt user to enter a number
System.out.println("Please enter an integer: ");
double num = sc.nextDouble();
// part 3: tell whether number is odd or even
for (int i=0; i>0; i+=2) {
if(i%2);
}
}
}
That's all I have, but I don't know what to do to tell if the number is even because I can't use integer or double with boolean.
Aucun commentaire:
Enregistrer un commentaire