Chat with us, powered by LiveChat Give an example of a?while?loop, then provide the equivalent do-while loop and for loop.? Then give a different example of a?do-while?loop, along with the equivalent while loop and for lo | WriteDen

Give an example of a?while?loop, then provide the equivalent do-while loop and for loop.? Then give a different example of a?do-while?loop, along with the equivalent while loop and for lo

1.Give an example of a while loop, then provide the equivalent do-while loop and for loop.  Then give a different example of a do-while loop, along with the equivalent while loop and for loop. Finally, give an example of a for loop, along with the equivalent while loop and do-while loop. Use your examples to illustrate the advantages and disadvantages of each looping structure, and describe those advantages and disadvantages.

Your Discussion should be at least 250 words in length, but not more than 750 words. Once you’ve completed your initial post, be sure to respond to the posts of at least 3 of your classmates.

2.attached

CS 1102 – Unit 2 Programming Assignment

First create a new Java class for this assignment. You should start in Eclipse with your CS1102 project from the previous assignment.

• Select "New"->"Class" from the File menu. • Enter the Name "Quiz". • Check the box "public static void main(String[] args)". • Click "Finish".

Now have your program ask a multiple-choice quiz question. You should create your own original quiz question.

• Create a String called "question" and initialize it to the question you want to ask. Use the characters "n" to start a new line. For example: String question = "What is a quiz?n"; (Use your own quiz question, not this one.)

• Add multiple choices starting with "A", "B", "C", "D", and "E" using the "+=" operator and "n". question += "A. a test of knowledge, especially a brief, informal test given to studentsn";

Ask the user your question using "JOptionPane.showInputDialog".

• Add the following import statement at the top of your code, before "public class Quiz", to give your program access to JOptionPane. import javax.swing.JOptionPane;

• Ask your question and store the answer in a String. In particular, add the following statement in your main method after setting all the lines of your question String. String answer = JOptionPane.showInputDialog(question);

Try running your program.

• Select "Run Configurations…" from the Run menu. • Change the Name from "SuperPower" to "Quiz". • Change the Main Class from "SuperPower" to "Quiz". • Click "Apply". • Click "Run".

A dialog box should appear with your question and a text field for the answer. (In the Virtual Lab, a "File Changed" dialog may pop up. Click "Yes". This will bring the main Eclipse window to the front, hiding the message dialog from your program. Move the main Eclipse window or minimize it, and you will see the message dialog behind it.)

Now modify your program to check the answer.

• Change the answer to upper case so lower-case input works. answer = answer.toUpperCase();

• Use an if statement to check the answer and display a message if it is correct. For example, if the correct answer is "A": if (answer.equals("A")) { JOptionPane.showMessageDialog(null,"Correct!"); }

Run your program and enter various answers. Make sure you get the correct response.

Modify your program so that it responds differently to different input.

• It should display one message if the answer is correct, like "Correct!" • It should display a different message if the answer is valid ("A", "B", "C", "D", or "E") but

incorrect, like "Incorrect. Please try again." • It should display a third message if the answer is invalid (anything other than single characters

"A", "B", "C", "D", and "E"), like "Invalid answer. Please enter A, B, C, D, or E."

Run your program and test each of these possibilities.

Modify your program so that it asks the question and responds with a dialog until the user enters the correct answer.

• Move the statements that record the answer and display a response into a while loop. • Use "break" or "return" to exit the loop when the answer is correct.

Now test your final program.

Upload the following for your Programming Assignment submission.

• Quiz.java • Screen shot showing the input dialog with the quiz question • Screen shot showing the message dialog for the correct answer • Screen shot showing the message dialog for a valid but incorrect answer • Screen shot showing the message dialog for an invalid answer

HOW OUR WEBSITE WORKS

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of 
HIGH QUALITY & PLAGIARISM FREE.

Step 1

To make an Order you only need to click ORDER NOW and we will direct you to our Order Page at WriteDen. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
 Deadline range from 6 hours to 30 days.

Step 2

Once done with writing your paper we will upload it to your account on our website and also forward a copy to your email.

Step 3
Upon receiving your paper, review it and if any changes are needed contact us immediately. We offer unlimited revisions at no extra cost.

Is it Safe to use our services?
We never resell papers on this site. Meaning after your purchase you will get an original copy of your assignment and you have all the rights to use the paper.

Discounts

Our price ranges from $8-$14 per page. If you are short of Budget, contact our Live Support for a Discount Code. All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.

Please note we do not have prewritten answers. We need some time to prepare a perfect essay for you.