creating a program that requires a secret code to unlock. The program should first welcome the user
Question:
creating a program that requires a secret code to "unlock." The program should first welcome the user and ask the user to input their name. Then, the program will greet the user using the entered name and ask whether they are ready to crack the code. If they type "yes" (using any combination of upper/lower-case letters) then the program should proceed to the next stage. Otherwise, it should finish at that point and produce no more output.
In order to "crack the code," the user must input a string, followed by two integers which satisfy the following conditions:
- The first input must be a string length of 4 characters.
- The second input can either be the number 23 or a number between 50 and 98, but not equal to 98.
- The third number must be a positive number (remember 0 is not positive) that is odd OR is divisible by 7.
As the user enters each input, the program should immediately check whether or not the input satisfies its respective requirement(s) listed above. If the requirement(s) is satisfied, then a "Correct!" confirmation should be printed out. If the requirement(s) is NOT satisfied, then an error message should be printed out, and the user cannot input any more numbers. (i.e. if the user inputs a string of length 3 as the first number, then the user has failed to crack the code, and cannot guess the first or second number.)
Please refer to the sample outputs below for formatting. (Any output statements from the program must match the sample formatting exactly.)
Sample Run 1:
Welcome. What is your name?
Barbie
Hello Barbie. Are you ready to crack the code?
no
Sample Run 2:
Welcome. What is your name?
Barbie
Hello Barbie. Are you ready to crack the code?
yes
PHASE 1
Enter a string:
bold
Correct!
PHASE 2
Enter a number:
33
Sorry, that was incorrect!
Better luck next time!
Sample Run 3:
Welcome. What is your name?
Barbie
Hello Barbie. Are you ready to crack the code?
yes
PHASE 1
Enter a string:
ring
Correct!
PHASE 2
Enter a number:
66
Correct!
PHASE 3
Enter a number:
34
Sorry, that was incorrect!
Better luck next time!
Sample Run 4:
Welcome. What is your name?
Barbie
Hello Barbie. Are you ready to crack the code?
yes
PHASE 1
Enter a string:
ring
Correct!
PHASE 2
Enter a number:
66
Correct!
PHASE 3
Enter a number:
33
Correct!
You have cracked the code!
Systems Analysis And Design
ISBN: 978-1119496489
7th Edition
Authors: Alan Dennis, Barbara Wixom, Roberta M. Roth