int pi_digits1=0;
int pi_digits2=0;
System.out.println("Would you like from starting to fixed no. or for a
range:\n1.Fixed no\n2.Range");
byte choice = input.nextByte();
if(choice ==1){
System.out.println("Enter the no. of digits after decimal within 1 million
of pi to see and play");
pi_digits2=input.nextInt();
}
else if(choice ==2){
System.out.println("Enter the smaller +ve no of range");
pi_digits1=input.nextInt();
System.out.println("Enter the larger +ve no of range");
pi_digits2=input.nextInt();
System.out.println("Check");
}
else{
System.out.println("Wrong choice.Program terminated");
}
When the choice is 1,loop works fine. But for the choice 2,after taking inputs for pi_digits2 ,it is still asking for inputs.
Check is also being printed,but program is strucked in input loop and hence further code is not being executed.
Program executed in Bluej environment
Aucun commentaire:
Enregistrer un commentaire