Can\'t quite get this right can someone help me before i miss the deadline. Writ
ID: 3570270 • Letter: C
Question
Can't quite get this right can someone help me before i miss the deadline.
Write a function named cointoss that simulates the tossing of a coin.
When you call the function, it should generate a random number in the range of 1 through 2.
If the random number is 1, the function should display "heads".
If the random number is 2, the function should display "tails".
Demonstrate the function in a program that asks the user how many times the coin should be tossed, and then simulates tossing the coin that number of times.
Report the total number of heads and tails.
Explanation / Answer
int h=0;
int t=0;
if(randomInt == 1) {
System.out.println("Heads");
h++;
}
else {
System.out.println("Tails");
t++;
}
}
System.out.println("Total number of heads are : "+ h);
System.out.println("Total number of tails are : "+ t);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.