hi we have a programming assignment which computes the volume of a barrel. I don't have a compiler yet and java is not yet recognized by my computer yet because I haven't downloaded any JDK yet because I don't know which one to download...Here's my code so far...Please just review my codes because I can't test them and this is my first programming ass in java..so i'm still a newbie..

import java.util.Scanner;

public class A1{
	public static void main(String args[])
	{
	double h, r1, r2; byte b;
	
	Sanner input = new Scanner(System.in);
	System.out.println("Enter r1 & r2");
	b = input.nextByte();
	r1 = input.nextDouble();
	r2 = input.nextDouble();

	System.out.print("Volume Of the barrel is= "
	+ (h*Math.Pi*(((2*r1)*(2*r1)) + ((r2)*(r2))) / 3));
	}
}

hi we have a programming assignment which computes the volume of a barrel. I don't have a compiler yet and java is not yet recognized by my computer yet because I haven't downloaded any JDK yet because I don't know which one to download...Here's my code so far...Please just review my codes because I can't test them and this is my first programming ass in java..so i'm still a newbie..

Try Java SE. Download JDK 6 Update 10 with NetBeans 6.1
http://java.sun.com/javase/downloads/index.jsp

The IDE is just personal preference. It's all free. You need to have a JDK installed. Trying to program without being able to compile is for the birds. You also need access to the Java reference pages.

http://java.sun.com/javase/6/docs/

You'll use them often and you ned to be able to look things up. You'll quickly find your typos with the compiler and the fact that it's Math.PI, not Math.Pi. You'll waste way too much time if you don't have a compiler and access to the docs. Scanner is misspelled, you don't use b, and h is uninitialized. The compiler errors will tell you this. Download and install one. You can't program on paper without experimenting.

import java.util.Scanner;

public class A1{
	public static void main(String args[])
	{
	double h, r1, r2; byte b;
	
	Sanner input = new Scanner(System.in);
	System.out.println("Enter r1 & r2");
	b = input.nextByte();
	r1 = input.nextDouble();
	r2 = input.nextDouble();

	System.out.print("Volume Of the barrel is= "
	+ (h*Math.Pi*(((2*r1)*(2*r1)) + ((r2)*(r2))) / 3));
	}
}
commented: Exactly, You gave the advice he needed, not the one he wanted ;) +3

there's no use in asking us to correct the errors in your code if you haven't even tried whether there are errors in your code to correct

wondering what kind of compiler you want to use for java code, is wondering if you should install car-wheels on your car, or the wheels of a couple of bycicles.

it's both round, but you'll always be better off with the standard

Here are some compiler errors: Sanner input = new Scanner(System.in) should be Scanner input = new Scanner(System.in) Also the <h> variable is never initialized so you will get an error.
Try doing h = 0, but then the result would be zero, since you never read it.

Also it is Math.PI with capital

Plus here is a link for the JDK:

http://www.java.com/en/download/index.jsp

yeah...I didn't noticed there were many typographical errors..lol..so.. it would be like this:

h = input.nextDouble();

and also which one should I download? I tried many updates now but NetBeans still seerches for a full JDK..that's why I can't proceed..I downloaded (netbeans-6.1-ml-javase-windows)..is this enough?will this work if I downloaded the right JDK?

Download 1.5 or higher. Honestly, how hard could it be to find a compiler and JVM? Lol

Have you tried the link I provided?

yup..I downloaded the link you provided..
actually I have Java(TM) 6 Update 10
& Java(TM) 6 Update 7

what else should I download?
I downloaded already a NetBeans Installer

yup..I downloaded the link you provided..
actually I have Java(TM) 6 Update 10
& Java(TM) 6 Update 7

what else should I download?
I downloaded already a NetBeans Installer

It's probably already installed. Get a command line, go to the directory where your A1 program is, and type:

javac A1.java

If you have made the correct corrections, it should compile and you should now have a file called A1.class. If you still have errors in the code, it should give you the errors and you can correct them. If you get something like this:

javac is not recognized as internal or external command...

you need to adjust the path in the Control Panel, then open up a new command window (changes in the Control Panel won't take effect till you exit the command window and start a new one).

If you get the .class file, type this at the command line:

java A1

and your program should run. If it doesn't post the error you get. None of this is using NetBeans yet. Once you have this accomplished and can run programs from th command line, Java is definitely installed correctly. Now run NetBeans, take a tutorial on how to use it, and go from there.

I promise this will be my last question..lol..
how can I change the path in the control panel?

I promise this will be my last question..lol..
how can I change the path in the control panel?

Now why would you make a promise like that? ;) Careful, someone could hold you to it!

http://java.com/en/download/help/path.xml
http://ccism.pc.athabascau.ca/html/vhd/javapath.xml

Before you can change the path, you'll have to find where the bin folder is. It's usually something like:

C:\Program Files\Java\jdk1.5.0_15\bin

but check to confirm. The numbers will be different since this is a different version release of Java

It should have a file called javac.exe in it.

Edit:

on the second link, rebooting the computer is overkill. Exiting the Control panel, then exiting the command window and opening another one is sufficient.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.