trouble with method call

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Mar 2009
Posts: 3
Reputation: lounestor is an unknown quantity at this point 
Solved Threads: 0
lounestor lounestor is offline Offline
Newbie Poster

trouble with method call

 
0
  #1
Mar 22nd, 2009
hi im a new memeber .iv started learning java recently. i was wondering could anyone help with this problem because i just cant seem to work out where i'm going wrong. its my method call thats giving me the proplem...i think. if anybody has any solutions i would be grateful


import javax.swing.*;
public class EurekaWater{
public static void main(String args[]){

String userInput,waterQty;
Double input,quantityWater, fee;

   userInput=JOptionPane.showInputDialog("enter number of home Owners");
   input=Double.parseDouble(userInput);
   
 for(int count=0; count<input; count++)
   {
   	
   	waterQty=JOptionPane.showInputDialog("Enter quantity of water user in cubic feet");
   	quantityWater=Double.parseDouble(waterQty);
   	
   	if(quantityWater<=1000){
   	
   		 fee=FlatRate;   	}
   	else if (quantityWater>1000&&quantityWater<=2000){
   		fee=FlatRatePlus;
   	}
   		
   	else if (quantityWater>2000&&quantityWater<=3000){
   		fee=FlatPlusPlus;   	}
   		
   	else {
   	
   		fee=HigherRate;   	}		
   	
   	JOptionPane.showMessageDialog(null,fee);
   }
   

}
  
  	public static double FlatRate()
   	{
   	
   		return 15.0;
   	}
   	
   	public static double FlatRatePlus (double units)
   	{
  			
   		double	cost=(units-1000)*.0175+15;
   		return cost;
   	}
   	
   	public static double FlatPlusPlus (double units)
   	{
 		double cost=((units-2000)*.02)+22.50;
   		return cost;	
   	}
   	public static double HigherRate (double units)
   		
   	{ 	double cost;	
   		return cost=70;
   	}	
  

  
}
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 332
Reputation: quuba is on a distinguished road 
Solved Threads: 53
quuba quuba is offline Offline
Posting Whiz

Re: trouble with method call

 
0
  #2
Mar 22nd, 2009
Invoke Your functions as functions with ().
fee = FlatRate(); //without parameter
fee = FlatRatePlus(quantityWater); //with parameter quantityWater.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 3
Reputation: lounestor is an unknown quantity at this point 
Solved Threads: 0
lounestor lounestor is offline Offline
Newbie Poster

Re: trouble with method call

 
0
  #3
Mar 23rd, 2009
thanks you so much. that's what i did last night too but it wasn't compiling but it did it straight away this morning or some reason. thanks for that
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC