我的任务是拆分我的程序,它允许用户输入一个数字数组,在1到10之间的奇数之后检查奇数是否是数组中5个数字的一个因子。当我运行程序时,复选框会给出一个输出,但程序的其余部分不会,有人解释为什么吗?。有人能帮我一下吗?或者寄一份样品,看看要换什么样的衣服才能用?程序如下:
import java.util.Scanner;
public class CheckboxExample{
Scanner s = new Scanner(System.in);
int num;
public static void main(String args[]) {
CheckBox c = new CheckBox();
new CheckboxExample(); // links to checkbox class
int array[] = new int[10];
}
public static void readInputArray(Scanner s){
System.out.println ("Please enter 10 random numbers"); // prompts the user to enter 10 numbers
int array[] = new int[10];
// declares variable num
try{
for (int i = 0; i < 10; i++) {
array[i] = s.nextInt(); // array declaration
}
}catch (Exception e){
System.out.println ("You have an error");
}
}
public static void readOddValue(Scanner s, int num){
System.out.println ("Please enter an odd number between 1 and 10");
try{
num = s.nextInt ();
if (num % 2 == 0){
do{
System.out.println ("\nYour number is even, enter an odd one");
num = s.nextInt ();
}while (num % 2 == 0);
}
if (num < 0 | num > 10){
do{
System.out.println ("Your number is outside of the range, try again");
num = s.nextInt ();
}while (num < 0 | num > 10);
}
}catch (Exception e){
System.out.println ("error");
}
}
public static void calculateFactors(int[] array, int num){
try{
for (int i = 0; i < 10 ; i++){
if (array[i] % num == 0) {
System.out.println("Your number is a factor of " + array[i] );
}
}
}catch (Exception e){
System.out.println ("error");
}
}
}
暂无答案!
目前还没有任何答案,快来回答吧!