Product calculation P23CS399
DESCRIPTION:
★ This program is used to calculate the included and excluded tax of products. It contains a class "Product Tax" With methods "getData()", "etcal() " and " Itcal() ".
getData() is used to get the basic details of the products like Name, Quantity, Price and Tax.
★ etcal() is used to calculate the Excluding Tax of products.
★ itcal() is used to calculate the Including Tax of the products.
PROGRAM:
public class ProductTax{
string pname;
int Qty;
float price;
float tax;
float totalamt;
float totalprice;
void getData(String r,int s,float x, float y)
{
pname=r;
Qty=s;
price=x;
tax=y;
System.out.println("\nProduct Name:"+pname);
System.out.println("\nQuantity:"+Qty);
System.out.println("\nPrice per piece:"+price);
System.out.println("\nTax:"+tax);
}
void etcal()
{
float totalprice=(Qty*price);
float totalamt=(totalprice*tax/100);
System.out.println("\nTotalAmount:"+(totalprice+totalamt));
}
void Itcal()
{
System.out.println("\noriginal price:"+(price*tax/100));
}
public static void main(String[] args)
{
System.out.println("\t\t<======Excluding Tax=====>");
ProductTax PT=new ProductTax();
PT.getData("pen",4,25,10);
PT.etcal();
ProductTax PT2=new ProductTax();
System.out.println("\n\n\t\t<=====Including Tax=====>");
PT2.getData("table",1,2000,30);
PT.Itcal();
}
}
OUTPUT:
<======Excluding Tax=====>
Product Name:pen
Quantity:4
Price per piece:25.0
Tax:10.0
TotalAmount:110.0
<=====Including Tax=====>
Product Name:table
Quantity:1
Price per piece:2000.0
Tax:30.0
original price:2.5
Comments
Post a Comment