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.


>> REGISTER NOW TO START POSTING


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

Results 1 to 5 of 5

Thread: Re: Java Newbie Code Problem

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java Newbie Code Problem

    Please help me too I have got nearly the same question. I don't know how to Change my program so that the hourly rate is an input by the user.
    ive got as far as.

    /**
    * @(#)MathDemo.java
    *
    * MathDemo application
    *
    * @author
    * @version 1.00 2012/4/23
    */
    //import java.util.Scanner;
    public class MathDemo {

    public static void main(String[] args) {
    //rate is the value of hourly pay
    // Scanner in = new Scanner(System.in);
    double rate = 80.00;
    System.out.println("value of rate is " + rate);
    //rate = Integer.parseInt(args[0]);
    //pay is value of weekly pay
    double pay = 40 * rate;
    System.out.println("the value of pay is " + pay);

    //anualPay is the value of a year's work
    int bonus = 100;
    double annualPay = pay * 12 + bonus * 12;
    System.out.println("annual salary is $ " + annualPay);




    }
    }

    do I need java.util.Scanner to do so please give me a direction thank's


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Java Newbie Code Problem

    Please do not hijack other people's posts, Especially when those posts are over 2 years old. I have moved your post.

  3. #3
    Member
    Join Date
    Jan 2012
    Posts
    33
    My Mood
    Confused
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Java Newbie Code Problem

    ....edited by moderator
    Last edited by copeg; April 24th, 2012 at 11:05 AM.

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Java Newbie Code Problem

    @CjStaal, please read the forum rules and the following:
    [url]http://www.javaprogrammingforums.com/cafe/9544-problem-spoon-feeding.html[/ur

  5. #5
    Member
    Join Date
    Aug 2011
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java Newbie Code Problem

    If you look at what you've written so far. You have your Scanner import statement and then you create a scanner BUT you have them as comments so there not actually used when you run the program. Your first step would be to change that.
    You then want the input value as a double so look here Scanner (Java 2 Platform SE 5.0)
    And you will find a method for finding the next double.
    You use this when you assign the value to your double, just as you have already done in your program but it will be = in.scannerMethod() the "in" bit refers to the name of the scanner object you created

Similar Threads

  1. Help!, newbie, interested in Java, Very simple code, completely stuck!
    By munkybunky in forum What's Wrong With My Code?
    Replies: 4
    Last Post: June 30th, 2011, 07:25 AM
  2. Newbie Question on a Code - I don't know if this is Java
    By fresca in forum Java Theory & Questions
    Replies: 4
    Last Post: April 7th, 2011, 08:39 PM
  3. Java Newbie: How to Code Node and its Neighbors?
    By ke3pup in forum Java Theory & Questions
    Replies: 0
    Last Post: April 20th, 2010, 01:00 AM
  4. Re: Java Newbie Code Problem
    By erinbasim in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 17th, 2010, 02:05 AM
  5. [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