DEV Community

AmalaReegan
AmalaReegan

Posted on

Day 15 Task 1

Task 1:

  1. Create a class called 'Jewellery'
  2. Create below static variables: static int goldPrice = 7100; static int silverPrice = 150; 2.1. Create below non-static variables int making_charges, wastage;
  3. Create main method.
  4. Inside main method, create instance as below Jewellery jewel1 = new Jewellery(); Jewellery jewel2 = new Jewellery();
  5. Using jewel1, assign making_charges and wastage.
  6. Using jewel2, assign making_charges and wastage.
  7. Call a non-static method as below. jewel1.bill(); jewel2.bill();
  8. Save, Compile and fix the error.
  9. 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

Image description

Top comments (0)