Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package q1;
- import java.util.Scanner;
- public class q6 {
- public static void main(String[]args){
- Scanner keyboard = new Scanner(System.in);
- int count=1,head=0,tail=0;
- char toss = 0;
- while(count<=8){
- System.out.print("h/t ");
- toss = keyboard.next().charAt(0);
- switch(toss)
- {
- case'h':
- case'H':
- head++;
- count++;
- break;
- case't':
- case'T':
- tail++;
- count++;
- break;
- default:
- System.out.println("invalid");
- }
- }
- System.out.println("Heads x "+head);
- System.out.println("Tails x "+tail);
- System.out.println("Heads percent "+(head*100)/8.0);
- System.out.println("Tails percent "+(tail*100)/8.0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement