Results 1 to 4 of 4
Thread: HELP, just started programming
- 08-06-2008, 08:24 PM #1
Member
- Join Date
- Aug 2008
- Posts
- 2
- Rep Power
- 0
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!!!
- 08-06-2008, 10:32 PM #2
Member
- Join Date
- Aug 2008
- Posts
- 3
- Rep Power
- 0
you just need to change String args[] instead of String[] args[].
- 08-07-2008, 08:59 AM #3
Member
- Join Date
- Aug 2008
- Location
- The Netherlands
- Posts
- 25
- Rep Power
- 0
actually, the right way to do this is:
Java Code:public static void main(String[] args) { //rest of method-body }
- 08-07-2008, 01:41 PM #4
Member
- Join Date
- Aug 2008
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
getting started
By ash in forum Advanced JavaReplies: 1Last Post: 07-23-2008, 10:31 AM -
JSP Getting Started.
By sukatoa in forum JavaServer Pages (JSP) and JSTLReplies: 7Last Post: 07-21-2008, 02:08 AM -
How do I get started?
By programmer-in-training in forum New To JavaReplies: 4Last Post: 01-11-2008, 07:45 AM -
Getting Started
By Doorsmaniac in forum Java AppletsReplies: 0Last Post: 11-24-2007, 03:40 AM -
I need help getting started
By Android in forum New To JavaReplies: 2Last Post: 10-30-2007, 04:46 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks