Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Re: Java Newbie Code Problem

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Thanked 0 Times in 0 Posts

    Default 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.

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

    within main(), declare a double called rate and set it equal to 80.00 Print out this variable using the following statement
    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
    rate = Integer.parseInt.(args(0));

    This is what i have so far and is comples and runs ok
    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;
    Last edited by helloworld922; January 17th, 2010 at 02:02 AM. Reason: Please use [code] tags!

  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Thanked 619 Times in 561 Posts
    Blog Entries

    Default Re: Java Newbie Code Problem

    For getting args from the command line, you need to use [] as opposed to ().
    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)
    double pay = rate * 40;

    Hopefully this should help you.

Similar Threads

  1. calling c code from java
    By sara in forum Java Native Interface
    Replies: 3
    Last Post: April 6th, 2013, 09:53 PM
  2. Newbie Programming problem
    By Pingu in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 17th, 2010, 02:10 AM
  3. [SOLVED] Java Newbie Code Problem
    By lee in forum What's Wrong With My Code?
    Replies: 6
    Last Post: January 16th, 2010, 03:05 PM
  4. code needed for the following problem
    By romilc in forum Java Theory & Questions
    Replies: 1
    Last Post: October 11th, 2009, 10:05 AM
  5. Convert Java Program to Java ME code
    By rinchan11 in forum Java ME (Mobile Edition)
    Replies: 1
    Last Post: October 5th, 2009, 10:18 PM