Advertisement
lol1234561

Untitled

Mar 1st, 2023
658
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.97 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Main {
  3.     public static void main(String[] args) {
  4. Scanner keyboard = new Scanner(System.in);
  5. char Maybe;
  6. int Q1;
  7. int Q2;
  8. int Q3;
  9. int correct = 0;
  10.  
  11.         System.out.println("Are you ready for a quiz?");
  12.         Maybe = keyboard.next().charAt(0);
  13.         if(Maybe =='y' || Maybe =='Y'){
  14.             System.out.println("Okay, here it comes!");
  15.             System.out.println("");
  16.             System.out.println("To answer the questions, please press 1 or 2.");
  17.  
  18.             System.out.println("Q1) Is this java?");
  19.             System.out.println("1) No." +
  20.                     " 2) Yes.");
  21.  
  22.             Q1 = keyboard.nextInt();
  23.             if(Q1 == 1){
  24.                 System.out.println("Incorrect");
  25.             } else if (Q1 == 2) {
  26.                 System.out.println("Correct");
  27.                 correct = correct + 1;
  28.             }else{}
  29.  
  30.             System.out.println("");
  31.             System.out.println("Q2) 1 is a char.");
  32.             System.out.println("1) No. 2) Yes.");
  33.             Q2 = keyboard.nextInt();
  34.             if(Q2 == 1){
  35.                 System.out.println("Correct");
  36.                 correct = correct + 1;
  37.             } else if (Q2 == 2) {
  38.                 System.out.println("Incorrect");
  39.             }else{}
  40.             System.out.println("");
  41.             System.out.println("Q3) Is cat a string? ");
  42.             System.out.println("1) Yes. 2) No.");
  43.             Q3 = keyboard.nextInt();
  44.  
  45.             if(Q3 == 1){
  46.                 System.out.println("Correct");
  47.                 correct = correct + 1;
  48.             } else if (Q3 == 2) {
  49.                 System.out.println("Incorrect");
  50.             }else{}
  51.  
  52.             System.out.println("You got " +
  53.                     correct + " answers correct");
  54.             System.out.println("");
  55.             System.out.println("Thank you for playing!");
  56.  
  57.         }else {
  58.             System.out.println("ok thank you for your time");
  59.          }
  60.  
  61.  
  62.  
  63.  
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement