Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote