我的程序是对的但是能不能亲帮忙帮我改一下下改的不一样一点。importjava.util.Scanner;importjava.security.SecureRandom;publicclassCai{publicstaticvoidmutiply(inta,intb){Secur...
我的程序是对的 但是能不能亲帮忙帮我改一下下 改的不一样一点。
import java.util.Scanner;
import java.security.SecureRandom;
public class Cai {
public static void mutiply(int a,int b) {
SecureRandom a4=new SecureRandom();
int a41=1+a4.nextInt(4);
int a42=-1-a4.nextInt(4);
Scanner input=new Scanner(System.in);
int c=input.nextInt();
if(c==a*b)
switch(a41) {
case 1:
System.out.println("Very good !");
break;
case 2:
System.out.println("Excellent !");
break;
case 3:
System.out.println("Nice work !");
break;
case 4:
System.out.println("Keep up your good work !");
break;
default:
break;
}else {
switch(a42) {
case -1:
System.out.println("No. Please try again !");
break;
case -2:
System.out.println("Wrong. Try once more !");
break;
case -3:
System.out.println("Don't give up !");
break;
case -4:
System.out.println("No. Keep trying !");
break;
default:
break;
}
mutiply(a,b); //if you input a wrong number will try again.
}
}
public static void main(String[] args) {
while(true) {
SecureRandom abc=new SecureRandom();
int a=1+abc.nextInt(9);
int b=1+abc.nextInt(9);
System.out.println("How much is "+a+" times "+b+" :");
mutiply(a,b);//get the different wrong or correct prompting.
}
}
}
展开