12. JAVA Program to convert milk vendor.
How does this program work?
- In this programme you will learn how to solve a question using java.
- Here the question is about to calculate gain of a milk vendor when adds 1litere of water for every 4literes of milk.
- This programme perform mathematical calculation and display the result using JAVA.
Here is the code
// Gain OR LOSS
import java.util.Scanner;public class vendor
{
public static void main(String args[])
{
int a,b,c;
double c1=3.25,c2=4.15,gain,d,e;
System.out.println("Enter the number of liters of milk purchased by the vendor:");
Scanner obj1=new Scanner(System.in);
a=obj1.nextInt();
b=a/4;
System.out.println("The amount of water added to the milk in liters is:\n"+b);
c=a+b;
System.out.println("The final quantity of milk and water mixture is:\n"+c);
d=a*c1;
e=c*c2;
gain=e-d;
System.out.println("The gain of the vendor is:\n"+gain+"rupees");
}
}