You are on page 1of 2

import java.util.

Scanner;
class Watch
{
String cd;
String type;
String cm;
double price;
double tcost;
double tax;
double dis;
double amt;

public Watch(String c,String ty,String cn,double pr)


{
cd=c;
type=ty;
cm=cn;
price=pr;

}
public void add()
{
tax=price*14/100;
if(type.equalsIgnoreCase("Analog"))
{
tcost=price*2/100;
}
else if(type.equalsIgnoreCase("Digital"))
{
tcost=price*20/100;
}
}
public void findDisc()
{
if(price<=3000)
{
dis=0*price;
}
else if(price>3000 && price<=8000)
{
dis=price*8/100;
}
else if(price>8000 && price<=15000)
{
dis=price*12/100;
}
else if(price>15000 )
{
dis=price*20/100;
}
}
public void show()
{
amt=price-dis+tax+tcost;
System.out.println("Watch Code :"+cd);
System.out.println("Watch type :"+type);
System.out.println("Company name :"+cm);
System.out.println("Type cost :"+tcost);
System.out.println("Watch price :"+price);
System.out.println("Discount :"+dis);
System.out.println("Tax :"+tax);
System.out.println("Total amount :"+amt);

}
public static void main (String args[])
{
Scanner scan=new Scanner(System.in);
System.out.println("Enter watch code:");
String wc=scan.nextLine();
System.out.println("Enter company name:");
String cn=scan.nextLine();
System.out.println("Enter watch type:");
String wt=scan.nextLine();
System.out.println("Enter the price");
double pr=scan.nextDouble();
Watch w1=new Watch(wc,wt,cn,pr);
w1.add();
w1.findDisc();
w1.show();
}
}

You might also like