Question: public class RaffleTicket { private String ownerName; private int ticketNum; public RaffleTicket ( String name ) { ownerName = name; ticketNum = getTicketNum ( )

public class RaffleTicket
{
private String ownerName;
private int ticketNum;
public RaffleTicket(String name)
{
ownerName = name;
ticketNum = getTicketNum();
}
private int getTicketNum()
{
/* Code to be implemented */
}
Which of the following can be used to replace /*Code to be implemented */ so that the code segment produces a random number between 1-100?
Consider the following class:
public class RaffleTicket
{
private String ownerName;
private int ticketNum;
public RaffleTicket(String name)
{
ownerName = name;
ticketNum = getTicketNum();
}
private int getTicketNum()
{
/* Code to be implemented */
}
Which of the following can be used to replace /*Code to be implemented */ so that the code segment produces a random number between 1-100?
return Math.random()*100;
return (int)(Math.random()*101);
return (int)(Math.random()*100+1);
return (int)(Math.random()*100);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!