Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Simple Java error

  • 29-06-2012 9: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