Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 1 of 1

Thread: astros vs. rangers- can someone help me with this?

  1. #1
    Junior Member
    Join Date
    Nov 2009
    Thanked 0 Times in 0 Posts

    Post astros vs. rangers- can someone help me with this?

    You are writing a prediction software program to see if the Houston Astros are going to win their game against the Texas Rangers. They will play nine innings. You need to simulate those innings. The Rangers are the away team and will bat first. Print out the ever innings results and the resulting score of the game.
    How do I do that? Well, there are many cool ways to write a simulation program, but let’s do a basic simulation:
    Every time a team plays their inning they have a 50% chance of scoring, if they do score, then randomize a run score between 1 and 6. If they don’t score, then give them a zero. Do this for each team in all nine innings. If the home team is winning in the bottom of the 9th inning, then they don’t have to play.
    Play Ball!

    import java.util.Random;
    public class Predictions
    	public static void main(String[]args)
    	int innings=9;
    	int totalast=(9*innings);
    	int totalran= (9*innings);
    	Predictions astros=new Predictions();
    	Predictions rangers=new Predictions();
    	Random astros= new Random();
        Random rangers=new Random();
        int min=0;
    	int max=6;
    	for(int i=0;astros>=1;rangers>=1;i++)
    		System.out.println (astros: + :rangers);
    Thanks guys. --Ian--
    Last edited by iank; November 5th, 2009 at 10:23 PM. Reason: please put your code between [code] tags