Help with Java code

Discussion in 'Software' started by RarestSpark, Dec 10, 2011.

  1. RarestSpark

    RarestSpark Private E-2

    Error at "public class Cricket.java{" line
    Error: "{" expected

    Heres my code:


    /*
    Converting fahrenheit to chirps
    */
    // Simple conversion calculator

    import java.util.Scanner;

    public class Cricket.java{



    public static void main(String [] args){
    Scanner reader = new Scanner(System.in);
    int fahrenheit, chirps;
    System.out.println("Welcome to the conversion calculator of chirps into fahrenheit.");
    System.out.println(" ");
    System.out.println("Please type the number of chirps heard in 14 seconds.");
    System.out.println(" ");
    chirps = reader.nextInt();
    fahrenheit = (chirps + 40);
    System.out.print("The converted temperature is ");
    System.out.print(fahrenheit);
    System.out.print(" degrees.");
    }
    }
     
  2. PC-XT

    PC-XT Master Sergeant

    Try taking off the ".java" part. The file extension isn't part of the class name. In fact, the compiled file ends with ".class"
    Code:
    public class Cricket{
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds