-
Notifications
You must be signed in to change notification settings - Fork 17
Assignment Question Password Checker with MCQ Question #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
question
Further information is requested
Comments
import java.util.Scanner;
public class Password_Checker1 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String setPassword,enterPassword;
System.out.println("Set Your Password: ");
setPassword=sc.nextLine();
System.out.println("Enter Your Password: ");
enterPassword=sc.nextLine();
int selectedAnswer;
if(setPassword.equals(enterPassword)){
System.out.println("Your password is correct...");
System.out.println("1. Who invented Java Programming?");
System.out.println("1. ) Guido van Rossum");
System.out.println("2. ) James Gosling");
System.out.println("3. ) Dennis Ritchie");
System.out.println("4. ) Bjarne Stroustru");
System.out.println("Select Answer: ");
selectedAnswer=sc.nextInt();
switch (selectedAnswer){
case 2:
System.out.println("Your answer is correct...");
System.out.println("2. Which component is used to compile, debug and execute the java program?");
System.out.println("1. ) JRE");
System.out.println("2. ) JIT");
System.out.println("3. ) JDK");
System.out.println("4. ) JVM");
System.out.println("Select your answer: ");
selectedAnswer=sc.nextInt();
switch(selectedAnswer){
case 3:
System.out.println("your answer is correct");
break;
default:
System.out.println("Your answer is incorrect try next year...");
break;
}
break;
default:
System.out.println("Your answer is incorrect try next year...");
break;
}
}else if(!setPassword.equals(enterPassword)){
System.out.println("Password is in correct try 3 times");
System.out.println("Enter Your Password: ");
enterPassword=sc.nextLine();
if(setPassword.equals(enterPassword)){
System.out.println("Your password is correct...");
System.out.println("1. Who invented Java Programming?");
System.out.println("1. ) Guido van Rossum");
System.out.println("2. ) James Gosling");
System.out.println("3. ) Dennis Ritchie");
System.out.println("4. ) Bjarne Stroustru");
System.out.println("Select Answer: ");
selectedAnswer=sc.nextInt();
switch (selectedAnswer){
case 2:
System.out.println("Your answer is correct...");
System.out.println("2. Which component is used to compile, debug and execute the java program?");
System.out.println("1. ) JRE");
System.out.println("2. ) JIT");
System.out.println("3. ) JDK");
System.out.println("4. ) JVM");
System.out.println("Select your answer: ");
selectedAnswer=sc.nextInt();
switch(selectedAnswer){
case 3:
System.out.println("your answer is correct");
break;
default:
System.out.println("Your answer is incorrect try next year...");
break;
}
break;
default:
System.out.println("Your answer is incorrect try next year...");
break;
}
}else{
System.out.println("Password is in correct try 2 times");
System.out.println("Enter Your Password: ");
enterPassword=sc.nextLine();
if(setPassword.equals(enterPassword)){
System.out.println("Your password is correct...");
System.out.println("1. Who invented Java Programming?");
System.out.println("1. ) Guido van Rossum");
System.out.println("2. ) James Gosling");
System.out.println("3. ) Dennis Ritchie");
System.out.println("4. ) Bjarne Stroustru");
System.out.println("Select Answer: ");
selectedAnswer=sc.nextInt();
switch (selectedAnswer){
case 3:
System.out.println("Your answer is correct...");
System.out.println("2. Which component is used to compile, debug and execute the java program?");
System.out.println("1. ) JRE");
System.out.println("2. ) JIT");
System.out.println("3. ) JDK");
System.out.println("4. ) JVM");
System.out.println("Select your answer: ");
selectedAnswer=sc.nextInt();
switch(selectedAnswer){
case 3:
System.out.println("your answer is correct");
break;
default:
System.out.println("Your answer is incorrect try next year...");
break;
}
break;
default:
System.out.println("Your answer is incorrect try next year...");
break;
}
}else{
System.out.println("Password is in correct try 1 times");
System.out.println("Enter Your Password: ");
enterPassword=sc.nextLine();
if(setPassword.equals(enterPassword)){
System.out.println("Your password is correct...");
System.out.println("1. Who invented Java Programming?");
System.out.println("1. ) Guido van Rossum");
System.out.println("2. ) James Gosling");
System.out.println("3. ) Dennis Ritchie");
System.out.println("4. ) Bjarne Stroustru");
System.out.println("Select Answer: ");
selectedAnswer=sc.nextInt();
switch (selectedAnswer){
case 3:
System.out.println("Your answer is correct...");
System.out.println("2. Which component is used to compile, debug and execute the java program?");
System.out.println("1. ) JRE");
System.out.println("2. ) JIT");
System.out.println("3. ) JDK");
System.out.println("4. ) JVM");
System.out.println("Select your answer: ");
selectedAnswer=sc.nextInt();
switch(selectedAnswer){
case 3:
System.out.println("your answer is correct");
break;
default:
System.out.println("Your answer is incorrect try next year...");
break;
}
break;
default:
System.out.println("Your answer is incorrect try next year...");
break;
}
}else{
System.out.println("Time out...");
}
}
}
}
}
} |
package June_22;
import java.util.Scanner;
public class PasswordChecker {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("note: user select right password then start MCQ EXAM...\n" +
"Set Password:");
String setPassword = sc.next();
System.out.println("Enter Password:");
String enterPassword = sc.next();
if (enterPassword.equals(setPassword)) {
System.out.println("You can start your MCQ exam");
System.out.println(" 1. Who invented Java Programming?\n"+
"1. Guido van Rossum\n"+
"2. James Gosling\n"+
"3. Dennis Ritchie\n"+
"4. Bjarne Stroustrup");
System.out.println("Select answer from options");
int enteredAnswer;
enteredAnswer=sc.nextInt();
int correctAnswer=2;
if(enteredAnswer==correctAnswer){
System.out.println("right answer");
int rightAnswer=3;
System.out.println("Q2) Which component is used to compile, debug, and execute the Java programs?\n"+
" 1. JRE\n"+
" 2. JIT\n"+
" 3. JDK\n"+
" 4. JVM\n"+
"Select answer from options");
enteredAnswer=sc.nextInt();
if(enteredAnswer==rightAnswer){
System.out.println("right answer");
}
else {
System.out.println("Wrong answer... Try next year");
}
}
else {
System.out.println("Wrong answer... Try next year");
}
} else if (!enterPassword.equals(setPassword)) {
System.out.println("Wrong password... try 2 more times out of 2");
System.out.println("Enter Password:");
enterPassword = sc.next();
if (enterPassword.equals(setPassword)) {
System.out.println("You can start your MCQ exam");
System.out.println(" 1. Who invented Java Programming?\n"+
"1. ) Guido van Rossum\n"+
"2. ) James Gosling\n"+
"3. ) Dennis Ritchie\n"+
"4. ) Bjarne Stroustrup");
System.out.println("Select answer from options");
int enteredAnswer;
enteredAnswer=sc.nextInt();
int correctAnswer=2;
if(enteredAnswer==correctAnswer){
System.out.println("right answer");
int rightAnswer=3;
System.out.println("Q2) Which component is used to compile, debug, and execute the Java programs?\n"+
" 1) JRE\n"+
" 2) JIT\n"+
" 3) JDK\n"+
" 4) JVM\n"+
"Select answer from options");
enteredAnswer=sc.nextInt();
if(enteredAnswer==rightAnswer){
System.out.println("right answer");
}
else {
System.out.println("Wrong answer... Try next year");
}
}
else {
System.out.println("Wrong answer... Try next year");
}
} else if (!enterPassword.equals(setPassword)) {
System.out.println("Wrong password... try 1 more times out of 1");
System.out.println("Enter Password:");
enterPassword = sc.next();
if (enterPassword.equals(setPassword)) {
System.out.println("You can start your MCQ exam");
System.out.println(" 1. Who invented Java Programming?\n"+
"1. ) Guido van Rossum\n"+
"2. ) James Gosling\n"+
"3. ) Dennis Ritchie\n"+
"4. ) Bjarne Stroustrup");
System.out.println("Select answer from options");
int enteredAnswer;
enteredAnswer=sc.nextInt();
int correctAnswer=2;
if(enteredAnswer==correctAnswer){
System.out.println("right answer");
int rightAnswer=3;
System.out.println("Q2) Which component is used to compile, debug, and execute the Java programs?\n"+
" 1) JRE\n"+
" 2) JIT\n"+
" 3) JDK\n"+
" 4) JVM\n"+
"Select answer from options");
enteredAnswer=sc.nextInt();
if(enteredAnswer==rightAnswer){
System.out.println("right answer");
}
else {
System.out.println("Wrong answer... Try next year");
}
}
else {
System.out.println("Wrong answer... Try next year");
}
} else if (!enterPassword.equals(setPassword)) {
System.out.println("Wrong password... try 0 more times out of 0");
}
}
}
else {
System.out.println("Enter Password:");
enterPassword = sc.next();
System.out.println("You have reached your try limit");
}
}}
|
package ifelse;
import java.util.Scanner;
import static java.lang.System.exit;
public class Password_Checker {
public static void main(String[] args) {
String pasw,pasw1,paws3,paws4 ;
int option1,option3,option4 ;
Scanner sc=new Scanner(System.in);
System.out.println("set the password ");
pasw=sc.next();
System.out.println("enter the password");
pasw1=sc.next();
if (! pasw.equals(pasw1)) {
System.out.println("try again ");
paws3= sc.next();
if (!paws3.equals(pasw)){
System.out.println("try again password");
paws4=sc.next();
if (!pasw.equals(paws4)) {
System.out.println("try next year");
exit(0);
}
else System.out.println("current password");
}
else System.out.println("current password");
}
else System.out.println("current password");
System.out.println("Q1. What is the capital of France?");
System.out.println("1. Paris");
System.out.println("2. London");
System.out.println("3. Berlin");
System.out.println("4. Madrid");
System.out.print("Choose any one option ");
option1=sc.nextInt();
switch (option1) {
case 1:
System.out.println("Current Answer");
break;
case 2, 4, 3:
System.out.println("Wrong answer Try next time");
exit(0);
break;
default:
System.out.println("choose between 1 to 4 only try again");
}
System.out.println("Q1. Which planet is known as the “Red Planet”");
System.out.println("1. Venus");
System.out.println("2. Mars");
System.out.println("3. Jupiter");
System.out.println("4. Saturn");
System.out.print("Choose any one option ");
option3=sc.nextInt();
switch (option3) {
case 1, 4, 3:
System.out.println("Wrong answer Try next time");
exit(0);
break;
case 2:
System.out.println("Current Answer");
break;
default:
System.out.println("choose between 1 to 4 only try again");
}
System.out.println("Q1. Who wrote the play “Romeo and Juliet”?");
System.out.println("1. William Shakespeare");
System.out.println("2. Jane Austen");
System.out.println("3. Charles Dickens");
System.out.println("4. Mark Twain");
System.out.print("Choose any one option ");
option4=sc.nextInt();
switch (option4) {
case 1:
System.out.println("Current Answer");
break;
case 2, 3, 4:
System.out.println("Wrong answer Try next time");
exit(0);
break;
default:
System.out.println("choose between 1 to 4 only try again");
}
System.out.println("hello");
}
} |
package Loop;
import java.util.Scanner;
public class passwordChecker {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int pwd;
int c_pwd;
System.out.println("Enter Password : ");
pwd = scanner.nextInt();
System.out.println("Confirm Password : ");
c_pwd = scanner.nextInt();
if (c_pwd != pwd) {
System.out.println("Password is Incorrect ... 2 chances remain");
c_pwd = scanner.nextInt();
}if (c_pwd != pwd) {
System.out.println("Password is Incorrect ... 1 chances remain");
c_pwd = scanner.nextInt();
} if (c_pwd != pwd) {
System.out.println("Password is Incorrect ... 0 chances remain");
System.out.println("Password Locked");
}else if (c_pwd == pwd) {
System.out.println("Password is Correct");
int option;
String Answer;
System.out.println("1. Who invented Java Programming?\n" +
" 1. ) Guido van Rossum\n" +
" 2. ) James Gosling\n" +
" 3. ) Dennis Ritchie\n" +
" 4. ) Bjarne Stroustrup");
option = scanner.nextInt();
switch (option) {
case 1:
Answer = "Guido van Rossum";
break;
case 2:
Answer = "James Gosling";
break;
case 3:
Answer = "Dennis Ritchie";
break;
case 4:
Answer = "Bjarne Stroustrup";
break;
default:
Answer = "Choose the given options";
break;
}
String C_ans = "James Gosling";
System.out.println("Your answer is " + Answer);
if (Answer == C_ans){
System.out.println("Your answer is correct");
System.out.println("You may head to next question");
}else {
System.out.println("Your answer is incorrect");
System.out.println("Try again next Year");
return;
}
int option2;
String Answer2;
System.out.println(" 2. Which component is used to compile, debug and execute the java programs?\n" +
" 1. ) JRE\n" +
" 2. ) JIT\n" +
" 3. ) JDK\n" +
" 4. ) JVM");
option2 = scanner.nextInt();
switch (option2) {
case 1:
Answer2 = "JRE";
break;
case 2:
Answer2 = "JIT";
break;
case 3:
Answer2 = "JDK";
break;
case 4:
Answer2 = "JVM";
break;
default:
Answer2 = "Choose the given options";
break;
}
String C_ans2 = "JIT";
System.out.println("Your answer is " + Answer2);
if (Answer2 == C_ans2){
System.out.println("Your answer is correct");
//System.out.println("You may head to next question");
}else {
System.out.println("Your answer is incorrect");
System.out.println("Try again next Year");
}
}
}
}
|
package basic;
import java.util.Scanner;
public class CheckPassword {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String setPassword;
int maxAttempts = 3;
int attempt = 0;
System.out.println("Set a Strong Password: ");
setPassword = scanner.nextLine();
while (attempt < maxAttempts) {
System.out.print("Enter password: ");
String enteredPassword = scanner.nextLine();
if (enteredPassword.equals(setPassword))
{
System.out.println("Password correct! Starting MCQ test...");
runMCQTest();
break;
}
else
{
System.out.println("Incorrect password");
attempt++;
}
}
if (attempt == maxAttempts) {
System.out.println("No more attempts");
}
scanner.close();
}
private static void runMCQTest() {
Scanner scanner = new Scanner(System.in);
System.out.println("MCQ Test:");
System.out.println("1. Who Invented Java Programming Language?");
System.out.println("a) Guido van Rossum");
System.out.println("b) James Gosling");
System.out.println("c) Dennis Ritchie");
System.out.println("d) Bjarne Stroustrup");
char answer1 = scanner.next().charAt(0);
System.out.println("2. Which Component is used to compile, debug and execute the java programs?");
System.out.println("a) JRE");
System.out.println("b) JIT");
System.out.println("c) JDK");
System.out.println("d) JVM");
char answer2 = scanner.next().charAt(0);
if (answer1 == 'b') {
System.out.println("Correct ans");}
else {
System.out.println("Incorrect");}
if (answer2 == 'c') {
System.out.println("Correct ans");}
else {
System.out.println("Incorrect");}
scanner.close();
}
} |
package Assignment;
import java.util.Scanner;
public class if_else_Assignment_7_1 {
public static void main(String[] args) {
String pass1 ,pass2;
int count;
System.out.println("Set Your Password");
Scanner sc = new Scanner(System.in);
pass1 = sc.next();
System.out.println("Enter Your Password");
pass2 = sc.next();
for( count = 3; count >= 0; count--) {
if(!pass1.equals(pass2)) {
System.out.println("Enter the password " + count + " more time(s)");
} else {
System.out.println("Passwords match!");
break;
}
}
if(pass1.equals(pass2))
{ int option;
System.out.println(" Start the exam " );
System.out.println(" 1. Who invented Java Programming?\r\n"
+ " 1. ) Guido van Rossum\r\n"
+ " 2. ) James Gosling\r\n"
+ " 3. ) Dennis Ritchie\r\n"
+ " 4. ) Bjarne Stroustrup" );
Scanner scc = new Scanner(System.in);
option = scc.nextInt();
switch(option)
{
case 1:
System.out.println("Try next year");
break;
case 2:
System.out.println("correct Answer");
System.out.println("2. Which component is used to compile, debug and execute the java programs?\r\n"
+ " 1. ) JRE\r\n"
+ " 2. ) JIT\r\n"
+ " 3. ) JDK\r\n"
+ " 4. ) JVM");
int optionn = scc.nextInt();
switch(optionn)
{
case 1:
System.out.println("Try next year");
break;
case 2:
System.out.println("Try next year");
break;
case 3:
System.out.println("correct Answer");
break;
case 4:
System.out.println(("Try next year");
break;
default:
System.out.println("Invalid input");
break;
}
break;
case 3:
System.out.println("Try next year");
break;
case 4 :
System.out.println("Try next year");
break;
default:
System.out.println("Invalid input");
break;
}
}
}
} |
import java.util.Scanner;
public class passwordcheck {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String setPassword,enterPassword;
System.out.println("Set Your Password: ");
setPassword=sc.nextLine();
System.out.println("Enter Your Password: ");
enterPassword=sc.nextLine();
int selectedAnswer;
if(setPassword.equals(enterPassword)){
System.out.println("Your password is correct...");
System.out.println("1. Who invented Java Programming?");
System.out.println("1. ) Guido van Rossum");
System.out.println("2. ) James Gosling");
System.out.println("3. ) Dennis Ritchie");
System.out.println("4. ) Bjarne Stroustru");
System.out.println("Select Answer: ");
selectedAnswer=sc.nextInt();
switch (selectedAnswer){
case 2:
System.out.println("Your answer is correct...");
System.out.println("2. Which component is used to compile, debug and execute the java program?");
System.out.println("1. ) JRE");
System.out.println("2. ) JIT");
System.out.println("3. ) JDK");
System.out.println("4. ) JVM");
System.out.println("Select your answer: ");
selectedAnswer=sc.nextInt();
switch(selectedAnswer){
case 3:
System.out.println("your answer is correct");
break;
default:
System.out.println("Your answer is incorrect try next year...");
break;
}
break;
default:
System.out.println("Your answer is incorrect try next year...");
break;
}
}else if(!setPassword.equals(enterPassword)){
System.out.println("Password is in correct try 3 times");
System.out.println("Enter Your Password: ");
enterPassword=sc.nextLine();
if(setPassword.equals(enterPassword)){
System.out.println("Your password is correct...");
System.out.println("1. Who invented Java Programming?");
System.out.println("1. ) Guido van Rossum");
System.out.println("2. ) James Gosling");
System.out.println("3. ) Dennis Ritchie");
System.out.println("4. ) Bjarne Stroustru");
System.out.println("Select Answer: ");
selectedAnswer=sc.nextInt();
switch (selectedAnswer){
case 2:
System.out.println("Your answer is correct...");
System.out.println("2. Which component is used to compile, debug and execute the java program?");
System.out.println("1. ) JRE");
System.out.println("2. ) JIT");
System.out.println("3. ) JDK");
System.out.println("4. ) JVM");
System.out.println("Select your answer: ");
selectedAnswer=sc.nextInt();
switch(selectedAnswer){
case 3:
System.out.println("your answer is correct");
break;
default:
System.out.println("Your answer is incorrect try next year...");
break;
}
break;
default:
System.out.println("Your answer is incorrect try next year...");
break;
}
}else{
System.out.println("Password is in correct try 2 times");
System.out.println("Enter Your Password: ");
enterPassword=sc.nextLine();
if(setPassword.equals(enterPassword)){
System.out.println("Your password is correct...");
System.out.println("1. Who invented Java Programming?");
System.out.println("1. ) Guido van Rossum");
System.out.println("2. ) James Gosling");
System.out.println("3. ) Dennis Ritchie");
System.out.println("4. ) Bjarne Stroustru");
System.out.println("Select Answer: ");
selectedAnswer=sc.nextInt();
switch (selectedAnswer){
case 3:
System.out.println("Your answer is correct...");
System.out.println("2. Which component is used to compile, debug and execute the java program?");
System.out.println("1. ) JRE");
System.out.println("2. ) JIT");
System.out.println("3. ) JDK");
System.out.println("4. ) JVM");
System.out.println("Select your answer: ");
selectedAnswer=sc.nextInt();
switch(selectedAnswer){
case 3:
System.out.println("your answer is correct");
break;
default:
System.out.println("Your answer is incorrect try next year...");
break;
}
break;
default:
System.out.println("Your answer is incorrect try next year...");
break;
}
}else{
System.out.println("Password is in correct try 1 times");
System.out.println("Enter Your Password: ");
enterPassword=sc.nextLine();
if(setPassword.equals(enterPassword)){
System.out.println("Your password is correct...");
System.out.println("1. Who invented Java Programming?");
System.out.println("1. ) Guido van Rossum");
System.out.println("2. ) James Gosling");
System.out.println("3. ) Dennis Ritchie");
System.out.println("4. ) Bjarne Stroustru");
System.out.println("Select Answer: ");
selectedAnswer=sc.nextInt();
switch (selectedAnswer){
case 3:
System.out.println("Your answer is correct...");
System.out.println("2. Which component is used to compile, debug and execute the java program?");
System.out.println("1. ) JRE");
System.out.println("2. ) JIT");
System.out.println("3. ) JDK");
System.out.println("4. ) JVM");
System.out.println("Select your answer: ");
selectedAnswer=sc.nextInt();
switch(selectedAnswer){
case 3:
System.out.println("your answer is correct");
break;
default:
System.out.println("Your answer is incorrect try next year...");
break;
}
break;
default:
System.out.println("Your answer is incorrect try next year...");
break;
}
}else{
System.out.println("Time out...");
}
}
}
}
}
}
|
import java.util.Scanner;
public class password_checker {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String setPassword,enterPassword;
System.out.println("Set your password:");
setPassword=sc.nextLine();
System.out.println("Enter your password:");
enterPassword=sc.nextLine();
int selectAnswer;
if(setPassword.equals(enterPassword)) {
System.out.println("Your password is correct...");
System.out.println("1.Who invented java programming?");
System.out.println("1) Guido var rossum");
System.out.println("2) James gosling");
System.out.println("3) Dennis ritchie");
System.out.println("4) Bjarne stroustru");
System.out.println("Select answer");
selectAnswer=sc.nextInt();
switch(selectAnswer) {
case 2:
System.out.println("Your answer is correct...");
System.out.println("2.Which component is used to complie,debug and execute the java program?");
System.out.println("1) JRE");
System.out.println("2) JIT");
System.out.println("3) JDK");
System.out.println("4) JVM");
System.out.println("Select your answer");
selectAnswer=sc.nextInt();
switch(selectAnswer) {
case 3:
System.out.println("your answer is correct");
break;
default:
System.out.println("Your answer is incorrect try next year...");
break;
}
break;
default:
System.out.println("Your answer is incorrect try next year....");
break;
}
}else if(!setPassword.equals(enterPassword)) {
System.out.println("Password is incorrect try 3 times");
System.out.println("Enter your password:");
enterPassword=sc.nextLine();
if(setPassword.equals(enterPassword)) {
System.out.println("Your password is correct....");
System.out.println("1.Who invented java programming?");
System.out.println("1) Guido var rossum");
System.out.println("2) James gosling");
System.out.println("3) Dennis ritchie");
System.out.println("4) Bjarne stroustru");
System.out.println("Select Answer:");
selectAnswer=sc.nextInt();
switch(selectAnswer) {
case 2:
System.out.println("Your answer is correct...");
System.out.println("2.Which component is used to complie,debug and execute the java program?");
System.out.println("1) JRE");
System.out.println("2) JIT");
System.out.println("3) JDK");
System.out.println("4) JVM");
System.out.println("Select your answer");
selectAnswer=sc.nextInt();
switch(selectAnswer) {
case 3:
System.out.println("your answer is correct");
break;
default:
System.out.println("Your answer is incorrect try next year...");
break;
}
break;
default:
System.out.println("Password is incorrect try 2 times");
System.out.println("Enter your password:");
enterPassword=sc.nextLine();
if(setPassword.equals(enterPassword)) {
System.out.println("1.Who invented java programming?");
System.out.println("1.Who invented java programming?");
System.out.println("1) Guido var rossum");
System.out.println("2) James gosling");
System.out.println("3) Dennis ritchie");
System.out.println("4) Bjarne stroustru");
System.out.println("Select answer:");
selectAnswer=sc.nextInt();
switch(selectAnswer) {
case 2:
System.out.println("Your answer is correct");
System.out.println("2.Which component is used to complie,debug and execute the java program?");
System.out.println("1) JRE");
System.out.println("2) JIT");
System.out.println("3) JDK");
System.out.println("4) JVM");
System.out.println("Select your answer:");
selectAnswer=sc.nextInt();
switch(selectAnswer) {
case 3:
System.out.println("your answer is correct");
break;
default:
System.out.println("Your answer is incorrect try next year.....");
break;
}
break;
default:
System.out.println("Your answer is incorrect try next year....");
break;
}
}else {
System.out.println("Time out....");
}
}
}
}
}
}
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Develop a Java program that implements a Password Checker and an MCQ Exam system. The program should:
Sample Output:
Set your password: p4n@in
Enter your Password: p4n
wrong password... try 2 more time out of 2
Enter your Password: p4n@
wrong password... try 1 more time
Enter your Password: p4n@34
wrong password... try 0 more time
Note: user select right password then start MCQ EXAM...
Select Answer: 2
wrong answer [ Try Next year ]
Note: if select Right Answer ask 2nd Question ...
Select Answer: 2
... continue with the next question
The text was updated successfully, but these errors were encountered: