Handwrite the Measurable interface The Measurable interface
Solution
6)public interface Measurable { //creating interface
public double getMeasure(double cost); //with one abstract method we need not to specify abstract keyword
}
type above lines and save the file with the name Measurable.java
7)import java.io.*;
import java.util.*;
public class Product implements Measurable //implementing interface
{
public double getMeasure(double cost) //implementation of getMeasure method
{
return double;
}
public static void main(String ar[])
{
double cost,cost1; //declaring double variable
Scanner s=new Scanner(System.in) //creating scanner object
cost=s.nextDouble();
Product pr=new Product(); //creating present class object
cost1=pr.getMeasure(cost); //calling method
System.out.println(\"The cost of the product is:\"+cost1);
}
}
