Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For the following section of code only y and n should be acceptedas inputs but w

ID: 3613083 • Letter: F

Question

For the following section of code only y and n should be acceptedas inputs but when I type yd or ns (for example) they function asif I had typed y or n. How do I change this?

do{ System.out.print("Do you want another calender (y/n)? "); choice=stdIn.next().charAt(0); }while(choice!='y'&&choice!='n'); }while(choice=='y'); }
etc. For the following section of code only y and n should be acceptedas inputs but when I type yd or ns (for example) they function asif I had typed y or n. How do I change this?

do{ System.out.print("Do you want another calender (y/n)? "); choice=stdIn.next().charAt(0); }while(choice!='y'&&choice!='n'); }while(choice=='y'); }
etc.

Explanation / Answer

please rate - thanks do{ System.out.println("Would you like another calendar(y/n)?"); choice=in.next(); }while(choice.compareTo("Y")!=0&&choice.compareTo("y")!=0&&choice.compareTo("n")!=0&&choice.compareTo("N")!=0); }while(choice.compareTo("Y")==0|| choice.compareTo("y")==0); }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote