Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. public class TossCounter
  2. {
  3. /***** CONSTANT SECTION *****/
  4.  
  5. public static void main(String[] args)
  6. {
  7. /***** DECLARATION SECTION *****/
  8.  
  9. String temp;
  10. int heads = 0, tails = 0;
  11. double headsPercentage, tailsPercentage;
  12.  
  13. /***** INITIALIZATION SECTION *****/
  14.  
  15. /***** INPUT SECTION *****/
  16. System.out.println("Flip a coin 8 times and enter the results as H or T:");
  17. temp = JOptionPane.showInputDialog("Enter 1st toss result: ");
  18. char side = temp.charAt(0);
  19. switch (side)
  20. {
  21. case "H":
  22. heads++;
  23. break;
  24. case "T":
  25. tails++;
  26. break;
  27. default:
  28. System.out.println("Input not recognized, use 'H' or 'T'.");
  29. break;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement