fork download
  1.  
  2. /**
  3.  * Write a description of class AssignmentOneF17 here.
  4.  *
  5.  * @author (Martha)
  6.  * @version (a version number or a date)
  7.  */
  8. import java.util.Scanner;
  9. public class AssignmentOneF17
  10. {
  11. public static void main(String[] args)
  12. {
  13. Scanner in = new Scanner(System.in);
  14. System.out.println("Enter your poker hand");
  15. String pokerhand = in.next();
  16. // A while loop will allow the program to run until the user inputs quit, then it will break out of the loop
  17. while (pokerhand != "quit"){
  18. if ((pokerhand.charAt(1)==pokerhand.charAt(3))&& (pokerhand.charAt(1)==pokerhand.charAt(5)) && (pokerhand.charAt(1)==pokerhand.charAt(7)) && (pokerhand.charAt(1)== pokerhand.charAt(9)))
  19. System.out.println("flush");
  20.  
  21.  
  22.  
  23. else if (((pokerhand.charAt(0)==pokerhand.charAt(2)) && (pokerhand.charAt(0)==pokerhand.charAt(4)) && (pokerhand.charAt(0)==pokerhand.charAt(6)))|| ((pokerhand.charAt(0)==pokerhand.charAt(2)) && (pokerhand.charAt(0)==pokerhand.charAt(4)) && (pokerhand.charAt(0)==pokerhand.charAt(8)))|| ((pokerhand.charAt(2)==pokerhand.charAt(4)) && (pokerhand.charAt(2)==pokerhand.charAt(6)) && (pokerhand.charAt(2)==pokerhand.charAt(8)))||((pokerhand.charAt(0)==pokerhand.charAt(2)) && (pokerhand.charAt(0)==pokerhand.charAt(6)) && (pokerhand.charAt(0)==pokerhand.charAt(8)))||((pokerhand.charAt(0)==pokerhand.charAt(4)) && (pokerhand.charAt(0)==pokerhand.charAt(6)) && (pokerhand.charAt(0)==pokerhand.charAt(8))))
  24.  
  25. System.out.println("four of a kind");
  26.  
  27.  
  28.  
  29. else if ((((pokerhand.charAt(0)==pokerhand.charAt(2)) && (pokerhand.charAt(0)==pokerhand.charAt(4)) && (pokerhand.charAt(6)==pokerhand.charAt(8)))||((pokerhand.charAt(4)==pokerhand.charAt(6)) && (pokerhand.charAt(4)==pokerhand.charAt(8)) && (pokerhand.charAt(0)==pokerhand.charAt(2)))||((pokerhand.charAt(0)==pokerhand.charAt(4)) && (pokerhand.charAt(0)==pokerhand.charAt(8)) && (pokerhand.charAt(2)==pokerhand.charAt(6)))||((pokerhand.charAt(0)==pokerhand.charAt(2)) && (pokerhand.charAt(0)==pokerhand.charAt(6)) && (pokerhand.charAt(4)==pokerhand.charAt(8)))||((pokerhand.charAt(2)==pokerhand.charAt(4)) && (pokerhand.charAt(2)==pokerhand.charAt(6)) && (pokerhand.charAt(0)==pokerhand.charAt(8)))||((pokerhand.charAt(0)==pokerhand.charAt(6)) && (pokerhand.charAt(0)==pokerhand.charAt(8)) && (pokerhand.charAt(2)==pokerhand.charAt(4)))||((pokerhand.charAt(0)==pokerhand.charAt(2)) && (pokerhand.charAt(0)==pokerhand.charAt(8)) && (pokerhand.charAt(4)==pokerhand.charAt(6)))||((pokerhand.charAt(2)==pokerhand.charAt(4)) && (pokerhand.charAt(2)==pokerhand.charAt(8)) && (pokerhand.charAt(0)==pokerhand.charAt(6)))||((pokerhand.charAt(0)==pokerhand.charAt(4)) && (pokerhand.charAt(0)==pokerhand.charAt(6)) && (pokerhand.charAt(2)==pokerhand.charAt(8)))))
  30. System.out.println("full house");
  31.  
  32.  
  33.  
  34. else if ((pokerhand.charAt(0)==pokerhand.charAt(2)) && (pokerhand.charAt(0)==pokerhand.charAt(4)) || (pokerhand.charAt(4)==pokerhand.charAt(6)) && (pokerhand.charAt(4)==pokerhand.charAt(8)) || (pokerhand.charAt(0)==pokerhand.charAt(4)) && (pokerhand.charAt(0)==pokerhand.charAt(8)) || (pokerhand.charAt(0)==pokerhand.charAt(2)) && (pokerhand.charAt(0)==pokerhand.charAt(6)) || (pokerhand.charAt(2)==pokerhand.charAt(4)) && (pokerhand.charAt(2)==pokerhand.charAt(6)) || (pokerhand.charAt(0)==pokerhand.charAt(6)) && (pokerhand.charAt(0)==pokerhand.charAt(8)) || (pokerhand.charAt(0)==pokerhand.charAt(2)) && (pokerhand.charAt(0)==pokerhand.charAt(8)) || (pokerhand.charAt(2)==pokerhand.charAt(4)) && (pokerhand.charAt(2)==pokerhand.charAt(8)) || (pokerhand.charAt(0)==pokerhand.charAt(4)) && (pokerhand.charAt(0)==pokerhand.charAt(6)))
  35. System.out.println("three of a kind");
  36.  
  37.  
  38.  
  39. else if ((pokerhand.charAt(0)==pokerhand.charAt(2)) || (pokerhand.charAt(0)==pokerhand.charAt(4)) || (pokerhand.charAt(0)==pokerhand.charAt(6)) || (pokerhand.charAt(0)==pokerhand.charAt(8)||(pokerhand.charAt(2)==pokerhand.charAt(4))||(pokerhand.charAt(2)==pokerhand.charAt(6))||(pokerhand.charAt(2)==pokerhand.charAt(8))))
  40. System.out.println("pair");
  41.  
  42.  
  43. else if (pokerhand.equals("quit"))
  44. break;
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58. }
  59. }
  60. }
  61.  
  62.  
  63.  
  64.  
  65.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:9: error: class AssignmentOneF17 is public, should be declared in a file named AssignmentOneF17.java
public class AssignmentOneF17
       ^
1 error
stdout
Standard output is empty