Create a java program that will Answer all three questions below the following q
ID: 3677460 • Letter: C
Question
Create a java program that will Answer all three questions below the following questions with the following requirements using for loops and do while statements.
Problem: The following is a program about PIN checking for bank.
Question 1: Rewrite this program by using for loop, and add a trying times limitation, which means the user is allowed to try entering PIN at most 3 times. If still not matching
in the 3 trying, the program will print out a message and stops.
The output will look like the following:
Question 2: Redo Question 1, but using do...while loop.
Question 3: What are the difference about the 3 loops (for, while, do...while)? Analyze
the advantages and disadvantages.
import java-util.Scanner publie elass EnterPI public atatie void rain string1 1gs Scanner keyboard e canner (System.in) t pLn-12345 MITCHELL .",, system . out .print 1n(*WELCOME TO TH System.out-print"ENTER YOUR PIN: int entry = keyboard.nextIn.(), BANK OF while enczypin System.out-printIn&RCORRECT; PIN. TRY AGAIN." ystem-out-print"ENTER YCOR PN: nery-keyboard.next Int (0 System. out .prine1n" ?IN CgerEp. You Now HAVE ACCESS TO YOUR ACCOUtr , "liExplanation / Answer
Please find the answers below :
1) using for loop:
2) using do..while loop :
3)
For loop is used when you know the no:of iteration needs to be executed, whereas a while loop is used when you need to execute some statements only till certain condition is to be true. do..while is like while loop but you want atlaest one time the loop body is to be executed.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.