import javax.swing.*;  
import java.io.*;
import java.io.InputStreamReader;

public class Weight2
 {
	public static void main(String[] args)throws IOException
	{
	
		double cost;
		double tax;
		cost=Double.parseDouble(JOptionPane.showInputDialog("Enter purchase amount"));
		double payment;
 	         payment=Double.parseDouble(JOptionPane.showInputDialog("Enter amount tendered"));
	
		BufferedReader CHANGE=new BufferedReader(new InputStreamReader(System.in));
		tax=Double.parseDouble(CHANGE.readLine());

        displayTax(getTax(cost,tax));
	
	setPayment(payment);
	setTax(tax);
	setCost(cost);
       displayCost(getCost(cost,tax));

	System.exit(0);	
	}
   public static double getTax(double y, double x)
		{
			
		double tax;
		tax=x*0.06;
		System.out.print("sales tax is:"+y);
		return y;
		}

	public static void setTax(double y)
		{
		double tax;
		tax=y;
		}
	
	
	
	public static double getCost(double x,double y)
		{
		double cost;
		cost=x+y;
		System.out.print("total cost is:"+x);
		return x;
		}
		
	public static void setCost(double x)
		{
		double payment;
		payment=x;
		}	


	public static double getPayment(double a, double x)
		{
		double payment;
		payment=x-a;
			System.out.print("youre change is:"+a);
		return a;
		}

	public static void setPayment(double a)
		{
		double cost;
		cost=a;
		}


	public static double displayCost(double x)
		
		{
			JOptionPane.showMessageDialog(null,"Total cost:"+x);
			return x;
		}
		
		public static void displayTax(double x)
		{
			JOptionPane.showMessageDialog(null,"with tax:"+x);
		
	
		}
}

please help me with this.. theres no error but the methods doesn't function

first you set Get/Set method in separate class

then write function in another class as main method and call getter/setter method....

or else just write main class ans function itself and don't write getter/setter method within same class..

you declared variable in class again you declared that same variable in get/set methods...so that initialization affects nothing...

so that declare variable and initialize it properly...

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.