0% found this document useful (0 votes)
29 views1 page

U 87866456

The document describes a class called ElectricalProduct that inherits from a parent Product class. It defines attributes and methods for the ElectricalProduct class including a constructor, display method, and main method to test it.

Uploaded by

Govind Bhardwazz
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views1 page

U 87866456

The document describes a class called ElectricalProduct that inherits from a parent Product class. It defines attributes and methods for the ElectricalProduct class including a constructor, display method, and main method to test it.

Uploaded by

Govind Bhardwazz
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

ing name; int categoryID; double price; Product(int productID,String name,int categoryID,double price){ this.productID=productID; this.name=name; this.categoryID=categoryID; this.

price=price; } } public class ElectricalProduct extends Product{ int voltageRange; int wattage; ElectricalProduct(int productID,String name,int categoryID,double price, int voltageRange, int wattage){ super(productID,name,categoryID,price); this.voltageRange=voltageRange; this.wattage=wattage; } public void display(){ System.out.println("Product ID: "+productID); System.out.println("Name: "+name); System.out.println("Category ID: "+categoryID); System.out.println("Price: "+price); System.out.println("Voltage Range: "+voltageRange); System.out.println("Wattage: "+wattage); } public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.println("Enter Product ID: "); int pid=input.nextInt(); System.out.println("Enter Name: "); String name=input.next(); System.out.println("Enter Catagory ID: "); int cid=input.nextInt(); System.out.println("Enter Price: "); double price=input.nextDouble(); System.out.println("Enter Voltage Range: "); int vrange=input.nextInt(); System.out.println("Enter Wattage: "); int wattage=input.nextInt(); System.out.println("****Details of Electrical Product****"); System.out.println(); ElectricalProduct p=new ElectricalProduct(pid,name,cid,price,vrange,watt age); p.display(); } }

You might also like