So I need to implement a do...while loop to where after the code runs once I ask
ID: 3913123 • Letter: S
Question
So I need to implement a do...while loop to where after the code runs once I ask if user “want to go again? Y/N” ... if they input string y I need it to repeat otherwise I need it to just end. My code is below. Could you please specify exactly where I need to put the repeat code and what I need to write to implement it. You do not have to repeat my code with the corrections, just please specify which line and what to write at each line. Please include all symbols so I don’t make any mistakes. Thank you very much! import java.util.* public class ConvertDateTw public static void main (String[] args) //Getting User Date Scanner stdin new Scanner(System.in); System.out.print("Please enter date to be converted. Example (May 21, 1995): String UserDate- stdin.nextLine() //Makes User's Date all Lowercase String UserDateLC = UserDate.toLowerCase(); //Gets 1st letter of date and uppercases it string UserDatelLe (-+UserDateLC . charAt (0)).toUpperCase(); //Finds 1st Space in user's date int IndexistSpace = UserDateLc.index0f(" "); //Finds Comma in User's date int IndexComma = UserDateLc.index0f("."); //Gets User's Month w/o 1st letter all lowecasesed String UserMonthw01L = UserDatelc, substring(1, IndexistSpace) ; //This combines two strings and creates user's converted month. eg (May String UserConvertedMonth = Use rDate1L + UserMonthw01L; 1,1 Top support MobaXterm by subscrbing to the professional edtion here: https://mobaxterm.mobatek.netExplanation / Answer
You just need to make changes in your main method like below: publis static void main(String args[]) { // Declare Scanner // declatre a variable choice String choice; do { // From your sysout of date for asking to user, till teh last sysout statement in // main method put here inside do block here.. // Now ask user for next iteration System.out.println("want to go again? Y/N"); choice = stdin.next(); } while(choice.equals("Y")); // end of main method } // other function of your remain same, and no code change is required there.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.