Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner keyboard = new Scanner(System.in);
- char Maybe;
- int Q1;
- int Q2;
- int Q3;
- int correct = 0;
- System.out.println("Are you ready for a quiz?");
- Maybe = keyboard.next().charAt(0);
- if(Maybe =='y' || Maybe =='Y'){
- System.out.println("Okay, here it comes!");
- System.out.println("");
- System.out.println("To answer the questions, please press 1 or 2.");
- System.out.println("Q1) Is this java?");
- System.out.println("1) No." +
- " 2) Yes.");
- Q1 = keyboard.nextInt();
- if(Q1 == 1){
- System.out.println("Incorrect");
- } else if (Q1 == 2) {
- System.out.println("Correct");
- correct = correct + 1;
- }else{}
- System.out.println("");
- System.out.println("Q2) 1 is a char.");
- System.out.println("1) No. 2) Yes.");
- Q2 = keyboard.nextInt();
- if(Q2 == 1){
- System.out.println("Correct");
- correct = correct + 1;
- } else if (Q2 == 2) {
- System.out.println("Incorrect");
- }else{}
- System.out.println("");
- System.out.println("Q3) Is cat a string? ");
- System.out.println("1) Yes. 2) No.");
- Q3 = keyboard.nextInt();
- if(Q3 == 1){
- System.out.println("Correct");
- correct = correct + 1;
- } else if (Q3 == 2) {
- System.out.println("Incorrect");
- }else{}
- System.out.println("You got " +
- correct + " answers correct");
- System.out.println("");
- System.out.println("Thank you for playing!");
- }else {
- System.out.println("ok thank you for your time");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement