![]() ![]() ![]() ("Level code :") //here im trying to prompt the user to enter another code to continue the loopĬase 'D' : ("Total Diploma student = ") Ĭase 'B' : ("Total Bachelor student = ") Ĭase 'M' : ("Total Master student = ") Ĭase 'P' : ("Total PhD student = ") ĭefault : I am writing a menu based program, and I am stuck in one part. Overview async function async function block break class const continue debugger do.while empty export Expression statement for for await.of for.in for.of function declaration function if.else import label let return switch throw try.catch var while with do. Right now I dont know how to prompt user to input code again to continue the loop, but I have typed in a few lines to prompt the code and it works as intended, but Im sure this is not the most efficient way of doing it?Īnd Im planning to break the loop once user entered the last input/entered an invalid codeĬase 'F' : ("Total Foundation student = ") Submitted by IncludeHelp, on NovemGiven numbers and we have to perform mathematical operations using java program. Control Statements In Java switch case & for Loop At first the control comes to initialization section in Java for loop. So I've tried using the for loop method, thanks to Andreas for giving an example :), and it worked! Here, we are performing multiple basic mathematical tasks using switch case statement and do while loop. How does the switch-case statement work The expression is evaluated once. TotalCash = foundationCash + diplomaCash + bachelorCash + masterCash + phdCash //here i want to calculate all the input entered The switch statement allows us to execute a block of code among many alternatives. } while (levelCode < 5) //i dont know what to put here in order to loop the switch case I have a simple problem, I wrote switch case inside while loop that has 5 cases. Here is what I have worked on, there are also notes. In this tutorial, we will learn how to use while and do while loop in Java with the help of examples. I am fairly a beginner and have only learn java for a few weeks, any suggestion is very appreciated. ![]() Then I want to sum all the cash received by each student level. Statements inside of the do while will be executed based on its instruction only if the condition of the loop is true the second time. I'm currently working on the code that will prompt student level type in code (switch case), and to determine the amount of cash for each type of student will receive. Continue statement inside a Do While loop causes the program control to skip the statements below it and go to the beginning of the loop. Is there a simple way to have the switch statement continually loop until the user gives the appropriate input That is, if the user replies with a value. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |