Results 1 to 9 of 9
Thread: Car cricket program
- 03-20-2012, 01:06 PM #1
- 03-20-2012, 01:35 PM #2
Re: javac is not recognized as an internal or external command error
Please start a new thread for a new topic.
If you don't understand my response, don't ignore it, ask a question.
- 03-20-2012, 09:20 PM #3
Re: Car cricket program
Agreed. Thread split from javac is not recognized as an internal or external command error
In future, whenever you have a question start your own thread -- they're free. Don't wake the dead, as you did this time, and don't attempt to hijack another poster's thread with your question.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 03-21-2012, 12:27 PM #4
Re: Car cricket program
okay my bad.
Well can anyone answer my question now?
If you are writing a program, such as a roll of the die how do you make it so that a number comes up a certain percent of the time compared to another?
for example a 4 comes up 33% of the time, how would you write it in code?
- 03-21-2012, 12:33 PM #5
Re: Car cricket program
Do you have the algorithm for that? Given an algorithm we could help you write the code in java.
If you don't understand my response, don't ignore it, ask a question.
- 03-22-2012, 02:29 AM #6
Re: Car cricket program
/*
@author = Joshua Fist
@version 1 (March 2012)
Assignment 1 for KXT101 (car cricket)
*/
import java.util.Scanner.*;
import java.util.Random.;
public class AssigOne112
{
public static void main (String[] args)
{
Scanner sc = new Scanner (System.in);
Random generator = new Random();
final int black = 0;
final int blue = 1;
final int cyan = 2;
final int dark grey = 3;
final int grey = 4;
final int green = 5;
final int light grey = 6;
final int magenta = 7;
final int orange = 8;
final int pink = 9;
final int red = 10;
final int white = 11;
final int yellow =12;
String name1, name2;
boolean first;
int innings = 0;
System.out.println("Enter a player's name"); //declaration
name1 = newString();
System.out.println("Enter a 2nd player's name"); //declaration
name2 = new String();
System.out.println("Will " + name1 + " be batting first?");
first = new boolean();
System.out.println("How many innings will be played?");
}
}
This is my program so far:
I need to create two objects "car" and "van/truck/bus/SUV"
then I need to make it so the chance an oncoming vehicle is a car is 9 out of 10.
How would I write this in my program?
- 03-22-2012, 02:32 AM #7
Re: Car cricket program
One simple way would be to use the Random class to generate a number from 1-10 and test if it is <= 9the chance an oncoming vehicle is a car is 9 out of 10.If you don't understand my response, don't ignore it, ask a question.
- 03-22-2012, 02:56 AM #8
Re: Car cricket program
how would i use the random class?
could you use an example?
- 03-22-2012, 03:48 AM #9
Similar Threads
-
How to code a program to send messages to a chat program?
By josh2992 in forum New To JavaReplies: 2Last Post: 04-02-2011, 12:57 PM -
How would I open a program from a single button of another program. Help...
By decgaid06 in forum New To JavaReplies: 13Last Post: 03-22-2011, 06:49 AM -
changing my program to array working program
By Chewart in forum New To JavaReplies: 39Last Post: 11-18-2009, 06:53 PM -
How to execute an External Program through Java program
By Java Tip in forum java.ioReplies: 0Last Post: 04-04-2008, 02:40 PM -
How to execute an External Program through Java program
By JavaBean in forum Java TipReplies: 0Last Post: 10-04-2007, 09:33 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks