server_crash 64 Postaholic

What version of Java are you using? 1.4.2 0r 1.5.0

Jeremy

As he stated above it might be the sdk your using. If your using an older version like me you will use the BufferedReader. If you use sdk 1.5 they got some Scanner() method or something in place of the BufferedReader.

server_crash 64 Postaholic

Dude, I really liked how you had the menu's, Ithought that was pretty cool. Overall the program looks pretty good. You might think about submiting it to the java code bank on this site.

server_crash 64 Postaholic

What do you mean you want to have a menu? Are you meaning a graphical menu, because your program looks like it runs at the command line. I think what you meant is you want something to list the available units of measure or something, if so let us know.

server_crash 64 Postaholic

System.out.print("Hello you");
I believe what you want is println() and not print()

he shouldn't have to set the classpath, as i believe it's done when the sdk is installed.

Since he's only got one line to print it won't make a diffrence if he uses print() over println().

Also I had to manually set the classpath when I installed the sdk, so it cant always be set correctly when its installed.

server_crash 64 Postaholic

Like someone stated above you should post the areas in which are causing you trouble. If it's just the basic structure of IO, or you dont know how to get the ASCII value of characters, or something else let us know. But you should never post and ask someone to write a program for you.

server_crash 64 Postaholic

What I really meant was that did you open the directory where the program was saved before trying to compile.
Example:
If you saved the program in C:/javawork
but if you are at the command line and and it says C:/documents and settings....blah blah it wont compile because thats not were the file was saved.

If you try to do this you'll get an error that says: error cannot read: Example.java
1 error

Im sure this is your problem because your error message is the same as above.
To fix this you need to:
at the command line type in: cd \DirectoryWereYouSavedTheJavaProgram
Then try to compile, and that should fix all your problems.

You posted that you tried this: C:\Documents and Settings\Owner>javac Hello.java
This is saying that your program is saved in C:\Documents and Settings\Owner but i dont know if you save your programs there or not.

I hope I was able to explain this good enough, I know it sounds confusing.
If the problem persists or if you are unclear on directions let me know.

server_crash 64 Postaholic

Did you save the java file in the right directory? Also have you set the classpath and stuff like that?

server_crash 64 Postaholic

Im positive they got a tutorial on this at java.sun.com

server_crash 64 Postaholic

When you say that you want to set the radius and stuff, do you mean that you want user input?

server_crash 64 Postaholic

what exactly are you needing help with?

server_crash 64 Postaholic

I believe this is something like what you are asking for..Let me know if it's not.

import java.io.*;

class PrimeChecker
{

 public static void main(String[] args) throws IOException
 {

   BufferedReader stdin = new BufferedReader(new InputStreamReader (System.in));
   String inData;
   int number = 0; 
   int count = 0;
  try {
   do {
       System.out.print("Enter a positive integer number: ");
       inData = stdin.readLine();
       number = Integer.parseInt(inData.trim());
     
       if (number > 0 && (number % 2) != 0)
       {
		System.out.println("The number is prime\n");
       }

       else if (number == 0)
       {
	System.out.println("Please enter a number larger than 0\n");
       }
	else 
 	 System.out.println("The number is not prime\n");
	count++;
    }
  

    while (!inData.equals("//exit"));
  }
  catch (NumberFormatException e) {}
	System.out.println("Exiting. Please wait....");
  
  
 }
}
server_crash 64 Postaholic

Im not sure that a do-while loop is the best way to go about this, might be though. Right now I dont have time to fix it but I can a little later.

server_crash 64 Postaholic

are you wanted to get input from the user and then output the results?

server_crash 64 Postaholic

I made a program that simulates the roll of a six sided dice. I had my program return a random number between 1 and 6. The weird thing is I get 4 like 6 out of 10 times each time I run the program. So is the random number genarator really random or is there a way to make numbers more random?

server_crash 64 Postaholic

are you wanting to use Input/Output???

server_crash 64 Postaholic

You have alot of conversion problems that need to be fixed. But even when they are fixed the program doesnt really work the way you have it. If you want to convert the input to a double do something like this:

Double d = Double.valueOf(BufferedReaderVariableName.readLine().trim());
double d2 = d.doubleValue();

server_crash 64 Postaholic

what exactly are you looking for in the game?

server_crash 64 Postaholic

It would have helped to have the code posted but I'll post some code with the bufferedReader that does work to hopefully help you...

import java.io.*;

class Poop
{
	public static void main(String[] args) throws IOException 
	{
	  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	  String inData;
	  int count = 0;
	  
	  do
	  {
	    
	    System.out.println("Enter some text");
	    inData = br.readLine();
	    count++;
	}
	

	while  (!inData.equals(""));
		System.out.println("You were promted: " + count + " times");
	
        }
}
}
server_crash 64 Postaholic

This isnt exactly what your looking for but it should give you an idea of how it kind of works. I hope this helps a little...

import java.io.*;

class Grade 
{
	public static void main(String[] args) throws IOException 
	{
	  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	  String inData;
	  double grade = 0;
	  double count = 0;
	  
	  do
	  {
	    
	    System.out.println("Enter the letter grade");
	    inData = br.readLine();
	     if (inData.equals("a"))
	     {
	       grade = grade + 4.0;
	     } 
	     else if (inData.equals("b"))
	     {
		grade = grade + 3.0;
	     }
	     else if (inData.equals("c"))
	     {
	   	grade = grade + 2;
	     }
	    else if (inData.equals("d"))
	    {
		grade = grade + 1;
	    }
	   else if (inData.equals("f"))
	   {
		grade = grade + 0;
	   }
	   count++;
	  
	}
	

	while  (!inData.equals(""));

	System.out.println("GPA = " + (grade / (count - 1)));
	
        }
}
server_crash 64 Postaholic

You can always play a sound from a file like this:

import java.awt.*;
import javax.swing.*;
import java.applet.*;
import java.awt.event.*;
import java.net.*;

public class Sound extends JFrame implements ActionListener {
		AudioClip song;
   public Sound() {
	super("Sounds");
	setSize(200,130);
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);	
	Container pane = getContentPane();
	FlowLayout flo = new FlowLayout();
	pane.setLayout(flo);
	JButton btn = new JButton("Press");
	pane.add(btn);
	btn.addActionListener(this);
        setContentPane(pane);
	setVisible(true);
   }

   public void actionPerformed(ActionEvent event) {


	
   String source = event.getActionCommand();
		 	
	if (source == "Press") {
		try { 
			URL songURL = new URL("file:  errorSound.wav");                
			song = JApplet.newAudioClip(songURL);
			song.play();
		} catch (MalformedURLException malform) {
				System.out.println(malform.toString());
                 }
	}
        else 
	{
	 }
   }
   
   public static void main(String[] arguments) {
	Sound sn = new Sound();
   }
}
server_crash 64 Postaholic

i unable to read a text file into my code i have the right code i think i just can not make it run with no errors

can you post the code?

server_crash 64 Postaholic

This is just a general question. I was wondering how you can make programs compile and run quicker? Does it have to do with the primative type you use or what?

server_crash 64 Postaholic

never mind. fixed it.

server_crash 64 Postaholic

I have been working on TicTacToe for some time now. I just now got it to work but it's not working properly. When somebody gets three in a row a label is suppose to show that a player has won but it does'nt. So I cant figure out why it's having trouble deciding if somebody has won or not. The code in which I think there is a problem is in Bold. Here is the code:

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class ButtonArray extends JFrame implements ActionListener {
  JButton btn[][];
  String player;
  JLabel lbl;

  public ButtonArray() {
	JPanel jp = new JPanel();
	Container pane = getContentPane();
	
	setSize(155,155);
	setTitle("Tic Tac Toe");
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	
	btn = new JButton[3][3];
	player = "X";
	
	for (int x=0; x<3; x++) {
		for (int y=0; y<3; y++) {
			btn[x][y] = new JButton(" ");
			btn[x][y].addActionListener(this);
			jp.add(btn[x][y]);
		}
	}
	
	JPanel jp2 = new JPanel();
	lbl = new JLabel("Status: player X to go next");
	jp2.add(lbl);
	
	
	pane.setLayout(new BorderLayout());
	pane.add(jp, BorderLayout.CENTER);
	pane.add(jp2,BorderLayout.SOUTH);
	setContentPane(pane);
	setResizable(false);
	setVisible(true);


	

   }


   public void actionPerformed(ActionEvent e) {

	
	for (int x=0; x<3; x++) {
	    for (int y=0; y<3; y++) {
		if (e.getSource() == btn[x][y]) {
			processEvent(x,y);


		}
		
	    }
	}
	
   }

[B] private boolean hasWon(int x, int y) {
	boolean won;
	won = true;
	
	for (int num=0; num<3; num++) {
		won = false;
		if (btn[x][num].getText().equals(player)) {
			won = true;
		
		}
		
	}
	if (!won) {
		won = false;
		for (int col=3; col<3; col++) {
			if (btn[col][y].getText().equals(player)) {
				won = true;
			
			}
		}
	}
	
	if (!won) {
		won = false; …
server_crash 64 Postaholic

How am i measuring them?
Whenever I sign on to the internet it pops up a little bubble icon thing and tells me what speed i am connecting to the internet.
Also I can right click on the connection and go to status and it will tell me what speed its connecting at...

server_crash 64 Postaholic

That is what I am connecting to the internet at...
NOT my download speed. just what I am connecting at.

server_crash 64 Postaholic

Why would my 56k modem be connecting at 12k and 18k? It has been doing this for about 2-3 weeks. Any ideas?

server_crash 64 Postaholic

I have both of the books wmivey just specified{java in 24 hours and java primer plus}. I would definately go with these.

server_crash 64 Postaholic

was it as hard as what you thought it was going to be?

server_crash 64 Postaholic

Has anyone taken the AP Computer Science course in high school taught in Java? if so can you tell me how hard it is and all that stuff? Even if you took the course taught in a diffrent language i would appreciate if you would tell me about it.

Thanks for the help...