# Re: Java Newbie Code Problem

• April 23rd, 2012, 04:45 PM
maxruas
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
• April 23rd, 2012, 09:14 PM
copeg
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.
• April 24th, 2012, 01:09 AM
CjStaal
Re: Java Newbie Code Problem
....edited by moderator
• April 24th, 2012, 11:04 AM
copeg
Re: Java Newbie Code Problem
[url]http://www.javaprogrammingforums.com/cafe/9544-problem-spoon-feeding.html[/ur
• April 26th, 2012, 04:36 AM
wdh
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