DEV Community

AmalaReegan
AmalaReegan

Posted on

Day 15 Task 2

Task 2

  1. Create a class called 'Shop'
  2. Create below static variables: static int doorNo = 5; static int discount = 10; 2.1. Create below non-static variables int price, weight;
  3. Create main method.
  4. Inside main method, create instance as below Shop product1 = new Shop(); Shop product2 = new Shop();
  5. Using product1, assign price and weight.
  6. Using product2, assign price and weight.
  7. Call a non-static method as below. product1.bill(); product2.bill();
  8. Save, Compile and fix the error.
  9. Inside bill() method, print price and weight.
  10. Inside main method and inside bill() method, print doorNo and discount

Source code

package payilagam;

public class Shop {
static int doorNo = 5;
static int discount = 10;
int price, weight;
public static void main(String[] args)
{
Shop product1 = new Shop();
Shop product2 = new Shop();
product1.bill(100,10);
product2.bill(500,50);
}
public void bill(int price,int weight)
{
System.out.println("price"+" "+price);
System.out.println("weight"+" "+weight);
}
}

O/P

Image description

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more