Results 1 to 4 of 4
  1. #1
    TankMurdoch is offline Member
    Join Date
    Aug 2008
    Posts
    2
    Rep Power
    0

    Default HELP, just started programming

    Hi folks, hope someone can help? I have just started learning Java and I have been asked to create a simple program to calculate wages after the hourly rate is entered in a command line argument. Here is the code:

    public class MathDemo
    {
    public static void main(String[] args[])
    {
    int rate = 0;

    rate = Integer.parseInt(args[0]);

    double pay;
    pay = rate * 40; //40 hours in a week
    System.out.println("The weekly pay is $" + pay);

    int bonus;
    bonus = 100; //monthly bonus

    double annualPay;
    annualPay = (pay * 52) + (bonus * 12);
    System.out.println("Annual Salary is $" + annualPay);
    }

    }

    Every time I try to compile I get the error:

    MathDemo.java:5: cannot resolve symbol
    symbol:method parseInt (java.lang.String[])
    location:class java.lang.Integer
    int rate = Integer.parseInt(args[0]);

    There is a little arrow underneath the dot on the bottom line. I cannot for the life of me figure it out, PLEASE HELP, IT IS DOING MY HEAD IN!!!

  2. #2
    gedelakranthi is offline Member
    Join Date
    Aug 2008
    Posts
    3
    Rep Power
    0

    Default

    you just need to change String args[] instead of String[] args[].

  3. #3
    Rooneyz is offline Member
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    25
    Rep Power
    0

    Default

    actually, the right way to do this is:
    Java Code:
    public static void main(String[] args)
    {
          //rest of method-body 
    }

  4. #4
    TankMurdoch is offline Member
    Join Date
    Aug 2008
    Posts
    2
    Rep Power
    0

    Default

    Thanks folks, worked a treat!! I knew it would be something simple!!

Similar Threads

  1. getting started
    By ash in forum Advanced Java
    Replies: 1
    Last Post: 07-23-2008, 10:31 AM
  2. JSP Getting Started.
    By sukatoa in forum JavaServer Pages (JSP) and JSTL
    Replies: 7
    Last Post: 07-21-2008, 02:08 AM
  3. How do I get started?
    By programmer-in-training in forum New To Java
    Replies: 4
    Last Post: 01-11-2008, 07:45 AM
  4. Getting Started
    By Doorsmaniac in forum Java Applets
    Replies: 0
    Last Post: 11-24-2007, 03:40 AM
  5. I need help getting started
    By Android in forum New To Java
    Replies: 2
    Last Post: 10-30-2007, 04:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •