2 Replies - 135 Views - Last Post: 04 February 2012 - 05:59 PM Rate Topic: -----

Topic Sponsor:

#1 lholmes  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 30-November 11

pay calculator-issues calling a method into main method

Posted 02 February 2012 - 07:43 PM

So I have to create a pay calculator where I am invoking a CalculateNetPay into the main method but I keep getting errors when I am trying this. The assignment is to create a net pay calculator with the user inputting hours and pay rate. Here is my code:
import java.io.*;
import java.util.*;


public class PayCalculator {
	
	private final static double OT_START  = 40.0;
	private final static double OT_ADJUST = 0.5;
	private final static double TAX       = 0.2;

    public static void main(String[] args) {
    	
    	Scanner input = new Scanner(System.in);
    	System.out.println("Input Hours worked <1 week> \n-->");
    	double hours = input.nextDouble();
    	System.out.println("Input Hourly pay \n-->");
    	double rate = input.nextDouble();
    	System.out.println();
    	System.out.println("Net pay: $%2f\n", calculateNetPay(hours, rate));
    	System.out.println("Hours until overtime: %6.2f\n", OT_START);
    	System.out.println("Overtime adjustment: %7.2f%%\n", OT_ADJUST);
    	System.out.println("Tax rate: %.2f%%\n", TAX);
    		
    	
    }
    
    private static double calculateNetPay(double hours, double rate) {
    	
    	double gross;
    	if(hours <= 40)
    		gross = rate * hours;
    	else
    		gross = rate * 40 + rate * 1.5 * (hours - 40);
    	return gross - 0.2 * gross;
    	
    }
    
    
}



My errors are:
line 28: cannot find symbol method println(java.lang.String,double)
line 29: cannot find symbol method println(java.lang.String,double)
line 30: cannot find symbol method println(java.lang.String,double)
line 31: cannot find symbol method println(java.lang.String,double)

I'm not really sure what I did wrong.

Is This A Good Question/Topic? 0
  • +

Replies To: pay calculator-issues calling a method into main method

#2 blackcompe  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 719
  • View blog
  • Posts: 1,692
  • Joined: 05-May 05

Re: pay calculator-issues calling a method into main method

Posted 02 February 2012 - 08:25 PM

If you'll have a look at the API, you'll see there's no method with that signature, i.e. no println method that takes a string and a double. There is however, a printf method that takes those arguments.
Was This Post Helpful? 0
  • +
  • -

#3 lholmes  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 30-November 11

Re: pay calculator-issues calling a method into main method

Posted 04 February 2012 - 05:59 PM

Thank you! Sometimes the smallest things confuse me, so I greatly appreciate it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1