can anyone help with this program I tried to get user input but everytime I change the celcius to double or move it I get an error code that says it may not have been initilized. thanks for any help.

import java.util.Scanner;

	 class conversion{
	 	public static void main(String args[]){
	 		Scanner tempature = new Scanner(System.in);
	 		float DegreesFahrenheit, DegreesCelcius;
	 		System.out.println(tempature.nextLine());
	    	         DegreesCelcius=4;
	    	         System.out.println(DegreesCelcius);
	 		DegreesFahrenheit= (DegreesCelcius+32)*9/5;
	 		System.out.println(DegreesFahrenheit);
	 		System.out.print("degrees");
	 		

	 	}
	}

Doesn't look much like javascript to me.

Airshow

Yep, moving to Java.

Edit: As for the not initialized problem, when you create the Celsius, be sure to initilize it when you declare it, ala this:

float celsius = 0.0;
Double celsius2 = 0.0;
int celsius3 = 0;

That SHOULD fix your IDE giving that "may not be initialized" error.

As for the program in general, you're not quite using the scanner class right.

Okay, the easiest explanation I can do without just showing source code (which I WILL do) is that you need to use the scanner class to assign values to variables, they won't work inside of println() methods, perhaps this example will demonstrate what I mean:

import java.util.Scanner;

public class Main 
{
    public static void main(String[] args)
    {
        /*The basic problem is that the scanner class needs to be used to "catch"
         * input and reference a variable to it.
         */
        Scanner keyIn = new Scanner(System.in);
        double tempC;

        //you only need to use System.out.println() to do output, not input.
        System.out.println("Enter temp in Celsius");
        tempC = keyIn.nextDouble(); // Or .nextLine, .nextInt, .next

        System.out.println(tempC + " degrees Celsius is " + ((9/5) * tempC + 32) +
                            " degrees Fahrenheit.");
    }

}
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.