Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: What am i doing wrong?

  1. #1
    Junior Member
    Join Date
    Mar 2023
    Location
    Sweden
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default What am i doing wrong?

    public class Scanner {
    int inch;
    double cmPerInch = 2.54;
    Scanner in = new Scanner(Systen.in);

    public static void main(String[] args) {
    System.out.print("How many inches? ");
    inch = in.nextLine();
    cm = inch * 2.54;
    System.out.print(inch + " in = ");
    System.out.println(cm + " cm");
    }



    }

    What am i missing? It wont run.. and im following directions of a book that says it will run and be working but no..
    Please help me out.

  2. #2
    Junior Member
    Join Date
    Mar 2023
    Location
    Vancouver, Canada
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: What am i doing wrong?

    Which book are you following?

    How are you trying to run it? Were any errors reported?

  3. #3
    Junior Member
    Join Date
    Mar 2023
    Location
    Sweden
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: What am i doing wrong?

    Im reading the book Think Java, second edition.

    Its the:
    Scanner in = new Scanner(Systen.in); saying that "System cannot be resolved to a variable"

    Same with:
    inch = in.nextLine();
    cm = inch * 2.54;
    System.out.print(inch + " in = ");
    System.out.println(cm + " cm");

  4. #4
    Junior Member
    Join Date
    Apr 2023
    Location
    Munich
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: What am i doing wrong?

    you have a type Systen instead of System. inch is an integer, so you neeed to use nextInt()

    int inch;
    double cm;
    double cmPerInch = 2.54;
    Scanner in = new Scanner(System.in);

    System.out.print("How many inches? ");
    inch = in.nextInt();
    cm = inch * cmPerInch;
    System.out.print(inch + " in = ");
    System.out.println(cm + " cm");

Similar Threads

  1. Replies: 4
    Last Post: February 21st, 2021, 11:03 AM
  2. Am I doing something wrong?
    By emkash01 in forum What's Wrong With My Code?
    Replies: 9
    Last Post: February 22nd, 2019, 11:17 AM
  3. What is wrong?
    By iMiTzi in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 10th, 2014, 08:48 AM
  4. Replies: 4
    Last Post: March 6th, 2014, 05:14 PM
  5. what wrong with this??
    By sephskie in forum What's Wrong With My Code?
    Replies: 3
    Last Post: January 14th, 2012, 07:50 PM