Im very new to programming, I was thought java in an intense three week college prep course and am now studying software development.
In my data structures and algorithms lecture we were asked to write a program based on Monte Carlo Simulations and the Irish Election on Friday,
We have to calculate the probability that 3 specific candidates of the 6 will finish last in any order. The probabilities are gotten from converting odds that paddy power bookies have given.
I just have no idea where to start and how to go about it, all I have so far is
import java.util.Random;
import java.util.Scanner;
public class election
{
public static void main (String []args)
{
Scanner myscan = new Scanner(System.in);
Random elect = new Random();
Double probability;
for(int i=1; i<10;i++)
{
probability=Math.Random();
if(probability == 0.98)
{
System.out.println("Michael D.Higgins is 1st");
}
else if(probability == 0.038)
{
System.out.println("Sean Gallagher is 2nd");
}
else if(probability == 0.029)
{
System.out.println(" Peter Casey is 3rd");
}
else if(probability == 0.024)
{
System.out.println("Liadh Ni Riadh is 4th");
}
else if(probability == 0.007)
{
System.out.println("John Freeman is 5th");
}
else if(probability == 0.005)
{
System.out.println("Gavin Duffy is 5th");
}
}
}
}
I realise this won't do as I want but I don't know where else to go, Sorry if this seems like a silly question but any and all help is greatly appreciated!!!! }
Aucun commentaire:
Enregistrer un commentaire