JAVA Lab Assignment #13:  Looping Lab with both types of loops. This lab demonstrates the use of the While Loop...

50.1K

Verified Solution

Question

Programming

JAVA

Lab Assignment #13:  Looping Lab withboth types of loops.

  • This lab demonstrates the useof the While Loop and the Do While Loop as error checkingmechanisms.
  • You will be using each ofthese loops to solve the same problem.
  • Please put them bothin the same program.
  • When you test the code, youwill not see a difference in the way they execute - but there willbe a difference in the logic when writing the code.
  • You will want to write arefined algorithm for both to see the logic differences.

Lab 13 Part a:

Using a While Loop, write the code that does the following:

  • Prompts the User for a scorebetween 0 and 100 (inclusive).
  • Repeats the prompt until theUser enters a valid number within the specified range.

Lab 13 Part b:

Using a Do While Loop, write the code that does thefollowing:

  • Prompts the User for a scorebetween 0 and 100 (inclusive).
  • Continues to prompt for scoresuntil the User enters a valid number within the specifiedrange.

Include the following in your programs:

  • A refined algorithm for eachlooping structure.
  • Internal documentation foryour code.

NOTE 1:

  • DO NOTuse the \"return 0\" code, end, break, or exit to force anexit from within your IF/ELSEstructure.  Declare allvariables within the data declaration section.
    • Let the programprogress to the end of the main function.
    • The end of the mainfunction is the only place that the “return 0” should beplaced.
    • A SWITCH statement isthe only place that the break command should be used.
  • DO NOTuse the \"continue\" statement.

NOTE 2:

1. Declare all variables within the data declaration section ofeach class and method.  (-.1)
2   Do not get input on the same line as a variabledeclaration.  
(-.1)

3. Do not place an equation for computation on the same line asdeclaring a variable.  (-.1)
3. Do not place an equation for computation on thesame line as an inputstatement.  (-.1)

Answer & Explanation Solved by verified expert
4.5 Ratings (987 Votes)
Solution Initiallize n to 1 For both the while and dowhileloops write the condition for n to not be in the range 0100 andcontinue till    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students