Problem 4. Write just the if structure for this method. - If the user has entere
ID: 3576650 • Letter: P
Question
Problem 4. Write just the if structure for this method. - If the user has entered a valid number between 1 and 9, say "thank you". Assign True to the boolean variable. - If the user enters a valid letter, keep giving him chances to enter a digit. - If the user enters a character not in the 0 - 9 range and also not an alphabetical character ("A" - "Z", "a" - "z"), assign False to the boolean variable. Assumptions you may safely make: - The user has been prompted and has entered a character. - The if structure is sitting inside of a while (true) loop. - The boolean variable will be returned to main() after the while (true) loop has ended. I will deduct points if you do not use methods from the Character wrapper class in your evaluation conditions
Explanation / Answer
if(1<num<9)
{System.out.println("thank you");
flag = true;}
if(Character.isLetter('num'))
{
System.out.println("You have enetered character, please enter digits");
Scanner num = new Scanner(System.in)
num= nextInt();
if(!(0<num<9 || 'a'<num<'z' || 'A'<num<'Z'))
flag = false;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.