Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. //Name: Dillon Ramesh
  2. //Date: 02/21/2019
  3.  
  4. import java.util.Scanner;
  5. public class Exercise3 {
  6.  
  7. public static void main(String[] args) {
  8. // TODO Auto-generated method stub
  9. //Variables
  10. String ans = null;
  11. String ansmc;
  12. String anstf;
  13. String ansyn;
  14. String ansmc2;
  15. String anstf2;
  16. //Input
  17. Scanner input= new Scanner (System.in);
  18. //Loop
  19. do
  20. {
  21. System.out.println("Welcome to the quiz");
  22. System.out.println("Question 1: \n What car do I drive?");
  23. System.out.println("A for Volkswagen, B for Honda, C for Chevrolet");
  24. ansmc=input.next();
  25. System.out.println("Question 2:\n My favourite sport is Hockey true of false?");
  26. anstf=input.next();
  27. System.out.println("Question 3: \n I have an acer laptop yes or no");
  28. ansyn=input.next();
  29. System.out.println("Question 4: \n What is my favourite colour?");
  30. System.out.println("A for Red, B for Blue, C for Green");
  31. ansmc2=input.next();
  32. System.out.println("Question 5: \n Both my parents are accountants true or false?");
  33. anstf2=input.next();
  34. if (ansmc.equalsIgnoreCase("A") || anstf.equalsIgnoreCase("T") || ansyn.equalsIgnoreCase("Y") || ansmc2.equalsIgnoreCase("B") || anstf2.equalsIgnoreCase("T"))
  35. {
  36. System.out.print("Correct");
  37. }
  38. else
  39. {
  40. System.out.println("Incorrect");
  41. }
  42. System.out.println("\nDo you want to retake the quiz?");
  43. ans=input.next();
  44. }while (ans.equalsIgnoreCase("Y"));
  45. System.out.println("Thanks for taking the quiz");
  46. }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement