0

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

  
}
2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by lounestor
0

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

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.