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;
   	}	
  

  
}

Recommended Answers

All 2 Replies

Invoke Your functions as functions with ().
fee = FlatRate(); //without parameter
fee = FlatRatePlus(quantityWater); //with parameter quantityWater.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.