# Re: Java Newbie Code Problem

• January 16th, 2010, 02:17 PM
erinbasim
Re: Java Newbie Code Problem
i need this program to be get solved plzz help me

Below is the problem that I have to solve in Java I have started the program and it compiles but I got a little lost after that.

1)
create a new java class named MathDemo. Add the main() method to this class

2)
within main(), declare a double called rate and set it equal to 80.00 Print out this variable using the following statement
Code :

`System.out.println(“The vaule of rate is + rate”);`
3) declare another double called pay. Assuming that rate represents hourly pay, compute the weekely pay (assuming a 40 hour work week) and store the result in pay.

4) Print out the value of pay using System.out.println().

5 ) compile and run the program

6)declare a int called bonus and assign it the value of 100.

7)Declare a variable called AnnualPay. Assuming bonus represents a monthly bonus, compute the annual salary and store it in the annualPay variable. Display the output in the following format:

Annual salary is \$ (answer hear)

8)save and run the MathDemo program.

9)Change your program so that the hourly rate is an input by the user using the first command line argument. Since command line arguments are string objects you will need to convert the Bstring to an int. use the following statement
Code :

`rate = Integer.parseInt.(args(0));`

This is what i have so far and is comples and runs ok
Code :

```public class MathDemo { public static void main (String[] args) { double rate = 80.00; System.out.println("The value of rate is " + rate); double pay = pay; } }```
• January 17th, 2010, 01:05 AM
helloworld922
Re: Java Newbie Code Problem
For getting args from the command line, you need to use [] as opposed to ().
Code :

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

You can type math expressions directly in using the variables and your Java program will compute them. Assign variables using "=" (without the quotes)
Code :

`double pay = rate * 40;`