943,981 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 387
  • Java RSS
Mar 22nd, 2009
0

trouble with method call

Expand Post »
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;
   	}	
  

  
}
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
lounestor is offline Offline
5 posts
since Mar 2009
Mar 22nd, 2009
0

Re: trouble with method call

Invoke Your functions as functions with ().
fee = FlatRate(); //without parameter
fee = FlatRatePlus(quantityWater); //with parameter quantityWater.
Reputation Points: 123
Solved Threads: 106
Posting Pro
quuba is offline Offline
573 posts
since Nov 2008
Mar 23rd, 2009
0

Re: trouble with method call

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
lounestor is offline Offline
5 posts
since Mar 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: problem with implementing MVC
Next Thread in Java Forum Timeline: Help with Dynamic graphs Graphs





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC