Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Simple Java error

  • 29-06-2012 10:14AM
    #1
    Closed Accounts Posts: 1,386 ✭✭✭


    Okay, so I've only started Java and for some reason, I can't get my converter to work, so far it looks like this;

    import java.util.Scanner;

    public class kgtolbs {

    public static void main(String[] args) {
    Scanner scans = new Scanner(System.in);
    double kg;
    double answer;
    System.out.println("KG to lbs converter.");
    System.out.println
    kg = scans.nextDouble();
    answer = kg * 2.205;
    System.out.println(kg+" kg is equal to "+answer+" lbs");








    {
    }

    }


    What could be wrong with it?


Comments

  • Registered Users, Registered Users 2 Posts: 214 ✭✭KMFCross


    Try This:

    import java.util.Scanner;

    public class kgtolbs
    {

    public static void main(String[] args)
    {
    Scanner scans = new Scanner(System.in);
    double kg;
    double answer;
    System.out.println("KG to lbs converter.");
    kg = scans.nextDouble();
    answer = kg * 2.205;
    System.out.println("" + kg + " kg is equal to " + answer + " lbs");
    }
    }


    When posting these questions it makes it easier if you quote the error message you are getting.


  • Closed Accounts Posts: 1,386 ✭✭✭Troxck


    KMFCross wrote: »
    Try This:

    import java.util.Scanner;

    public class kgtolbs
    {

    public static void main(String[] args)
    {
    Scanner scans = new Scanner(System.in);
    double kg;
    double answer;
    System.out.println("KG to lbs converter.");
    kg = scans.nextDouble();
    answer = kg * 2.205;
    System.out.println("" + kg + " kg is equal to " + answer + " lbs");
    }
    }


    When posting these questions it makes it easier if you quote the error message you are getting.

    Sorry for not stating the problem. :( Also, it worked, thanks a million!


  • Registered Users, Registered Users 2 Posts: 214 ✭✭KMFCross


    No Problem


Advertisement