Please use this method, there might be a lot of missing part in it, but please c
ID: 3592842 • Letter: P
Question
Please use this method, there might be a lot of missing part in it, but please complete containing those parts:
Import java.util.Scanner;
Scanner in=new Scanner(System.in);
system.out.println(“Enter a single positive int or positive double:”)
String input= in.nextLine();
Scanner lineOfInput=new Scanner (input);
If (lineOfInput.hasNextDouble()){
System.out.println(“theres a double in the input”);
}else{
System.out.println(“theres no double coming next in the input”);
}
Boolean inputIsValid=false;
//some kind of loop to run while (!inputIsValid){
//statements to validate input
inputIsValid=true;
while(userInput > 0) {
System.out.println(Math.sqrt(userInput));
userInput--;
}
}
Explanation / Answer
Import java.util.Scanner;
Scanner in=new Scanner(System.in);
system.out.println(“Enter a single positive int or positive double:”)
String input= in.nextLine();
Scanner lineOfInput=new Scanner (input);
If (lineOfInput.hasNextDouble()){
System.out.println(“theres a double in the input”);
}else{
System.out.println(“theres no double coming next in the input”);
}
Boolean inputIsValid=false;
//some kind of loop to run while (!inputIsValid){
//statements to validate input
inputIsValid=true;
while(userInput > 0) {
System.out.println(Math.sqrt(userInput));
userInput--;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.