Creating a java program involving four prize sums


Joined
Nov 21, 2021
Messages
1
Reaction score
0
Hey. So I'm currently studying loops and arrays in Java in my college class. I have an assigment and I've completed most of the questions but I'm stumped on one question in particular. It involves creating four prize sums and if the sum appears more than once, the user wins. Here is the question (question 3) in greater detail:

iBcij5P (1).png


This was my attempt at it but it doesn't seem to work. Could someone point out where I went wrong?


public static int GeneratePrize() {

int prizeNumber = (int)(Math.random() * 99 + 1);

if (prizeNumber >= 0 || prizeNumber <= 50) {

System.out.println("You won €10");
}

if (prizeNumber > 50 || prizeNumber <= 77) {

System.out.println("You won €20");
}

if (prizeNumber > 77 || prizeNumber <= 92) {

System.out.println("You won €50");

}
if (prizeNumber > 92 || prizeNumber <= 98 ) {

System.out.println("You won €100");

}
if (prizeNumber > 98 || prizeNumber <=100) {

System.out.println("You won €");
}
return prizeNumber;
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top