Lab 7
Lab 7
class B extends A{
public void dismsg(){
class C extends A{
public void dismsg(){
Product pr = arr[i];
System.out.println("id of product " + (i+1) + " : " + pr.getPid());
System.out.println("price of product " + (i+1) + " : "
+ pr.getPrice());
System.out.println("quantity of product " + (i+1) + " : "
+ pr.getQuantity());
System.out.println();
}
int max=0;
for(int i = 0 ; i < arr.length ; i++) {
Product p=arr[i];
int price=p.getPrice();
if(max<price);{
max=price;
}
}
System.out.println("higest Price"+max);
for(int i = 0 ; i < arr.length ; i++) {
Product p=arr[i];
int price=p.getPrice();
if(max==price)
{
System.out.println("the max product id"+p.getPid());
}
}
int total=0;
for(int i = 0; i < arr.length ; i++) {
Product pr = arr[i];
int a=pr.getPrice();
int b=pr.getQuantity();
System.out.println();
int xyz=a*b;
total=total+xyz;
}
System.out.println("total amount spend:"+total);
}
}
package MyNormalwork;
import MyNormalwork.Product;
import java.util.Scanner;
Product pr = arr[i];
System.out.println("id of product " + (i+1) + " : " + pr.getPid());
System.out.println("price of product " + (i+1) + " : "
+ pr.getPrice());
System.out.println("quantity of product " + (i+1) + " : "
+ pr.getQuantity());
System.out.println();
}
int max=0;
for(int i = 0 ; i < arr.length ; i++) {
Product p=arr[i];
int price=p.getPrice();
if(max<price);{
max=price;
}
}
System.out.println("higest Price"+max);
for(int i = 0 ; i < arr.length ; i++) {
Product p=arr[i];
int price=p.getPrice();
if(max==price)
{
System.out.println("the max product id"+p.getPid());
}
}
int total=0;
for(int i = 0; i < arr.length ; i++) {
Product pr = arr[i];
int a=pr.getPrice();
int b=pr.getQuantity();
System.out.println();
int xyz=a*b;
total=total+xyz;
}
System.out.println("total amount spend:"+total);
}
}