Dremendo Tag Line

Print 1 pen cost price in Java

Java Output - Question 14

In this question, we will see how to print the cost of one pen if the cost of 12 pens is Rs. 150 in java programming using the java output. To know more about java output click on the java output lesson.

Q14) Write a program in java to print the cost of one pen if the cost of 12 pens is Rs. 150.

Program

public class Q14
{
    public static void main(String args[])
    {
        System.out.println("Cost of 12 pens = Rs.150");
        System.out.print("Cost of 1 pen = Rs." + (150/12.0));
    }
}

Output

Cost of 12 pens = Rs.150
Cost of 1 pen = Rs.12.5
video-poster