Task 1:
- Create a class called 'Jewellery'
- Create below static variables: static int goldPrice = 7100; static int silverPrice = 150; 2.1. Create below non-static variables int making_charges, wastage;
- Create main method.
- Inside main method, create instance as below Jewellery jewel1 = new Jewellery(); Jewellery jewel2 = new Jewellery();
- Using jewel1, assign making_charges and wastage.
- Using jewel2, assign making_charges and wastage.
- Call a non-static method as below. jewel1.bill(); jewel2.bill();
- Save, Compile and fix the error.
- Inside bill() method, print making_charges and wastage. #
Source code:
**package payilagam;
public class Jewellery {
static int goldPrice = 7100;
static int silverPrice = 150;
int making_charges, wastage;
public static void main(String[] args)
{
Jewellery jewel1 = new Jewellery();
Jewellery jewel2 = new Jewellery();
jewel1.bill(5000,500);
jewel2.bill(3000,200);
}
public void bill(int making_charges,int wastage)
{
System.out.println("making_charges"+" "+making_charges);
System.out.println("wastage"+" "+wastage);
}
}**
Output
Top comments (0)