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

Edited 6 Years Ago by __avd: Added [code] tags. Encase your code in: [code] and [/code] tags.

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...

Edited 6 Years Ago by musthafa.aj: n/a

This article has been dead for over six months. Start a new discussion instead.