You are on page 1of 2

shahriarrahman7133@gmail.

com

Calculating Profit:

import javax.swing.JOptionPane;
public class Transaction
{public static void main(String args[])
{String p,q,s,u,v,o,k,g,h;
int x,y,a,b,t,r,z,n,m,e,i,j,c,w,l,d;
p=JOptionPane.showInputDialog("Total Investment:");
z=Integer.parseInt(p);
q=JOptionPane.showInputDialog("Enter Price of Rice purchased per kg:");
x=Integer.parseInt(q);
s=JOptionPane.showInputDialog("Amount of Rice purchased in KG:");
a=Integer.parseInt(s);
m=x*a;
o=JOptionPane.showInputDialog("Enter Price of Rice sold per kg:");
i=Integer.parseInt(o);
k=JOptionPane.showInputDialog("Amount of Rice sold in KG:");
j=Integer.parseInt(k);
e=i*j;
JOptionPane.showMessageDialog(null,"Total Price of Rice purchased:"+m,"Rice",
JOptionPane.PLAIN_MESSAGE);
JOptionPane.showMessageDialog(null,"Total Price of Rice sold:"+e,"Rice",
JOptionPane.PLAIN_MESSAGE);
u=JOptionPane.showInputDialog("Enter Price of Milk purchased per ltr:");
y=Integer.parseInt(u);
v=JOptionPane.showInputDialog("Amount of Milk purchased in ltr:");
b=Integer.parseInt(v);
n=y*b;
g=JOptionPane.showInputDialog("Enter Price of Milk sold per ltr:");
c=Integer.parseInt(g);
h=JOptionPane.showInputDialog("Amount of Milk sold in ltr:");
w=Integer.parseInt(h);
l=c*w;
JOptionPane.showMessageDialog(null,"Total Price of Milk
purchased:"+n,"Milk",JOptionPane.PLAIN_MESSAGE);
JOptionPane.showMessageDialog(null,"Total Price of Milk
sold:"+l,"Milk",JOptionPane.PLAIN_MESSAGE);
t=m+n;
JOptionPane.showMessageDialog(null,"Total Spending:"+t,"Spending",
JOptionPane.PLAIN_MESSAGE);
d=e+l;
JOptionPane.showMessageDialog(null,"Total Sold:"+d,"Sold",
JOptionPane.PLAIN_MESSAGE);
r=d-t;
JOptionPane.showMessageDialog(null,"Profit:"+r,"Profit",JOptionPane.PLAIN_MESSAGE);
JOptionPane.showMessageDialog(null,"Remaining:"+r,"Remaining",JOptionPane.PLAIN_MESS
AGE);
String print="Total Investment:"+z+"\n,price of Rice purchased:"+m+" \n,price of milk
purchased:"+n+"\n, price of Rice sold:"+e+"\n, price of milk sold:"+l+"\n, You Sold a
total of:"+d+"\n, Profit:"+r;
//(({JOptionPane.showMessageDialog(null,Print);}))
String message=String.format("Total Spending"+t+"\n Total Sold"+d+"\n Total
Profit"+r);
//((JOptionPane.showMessageDialog(null,message);))
}
}

You might also like