import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
System.out.println("Enter number of products: ");
int n=in.nextInt();
Product [] p=new Product[n];
for(int i=0;i<n;i++){
p[i].getData();
}
for(int i=0;i<n;i++){
p[i].display();
}
}
}
class Product{
private int p_code;
private String p_category;
private String p_warranty;
private double p_price;
public void getData(){
Scanner in=new Scanner(System.in);
System.out.println("Enter the product code: ");
String p_code=in.next();
System.out.println("Enter product category: ");
String p_category=in.next();
System.out.println("Enter the product warranty: ");
String p_warranty=in.next();
System.out.println("Enter the product price: ");
String p_price=in.next();
}
public void display(){
System.out.println("Product code: "+p_code);
System.out.println("Product category: "+p_category);
System.out.println("Product warranty: "+p_warranty);
System.out.println("Product price: "+p_price);
}
}
Comments
Leave a comment