how to create a java program using applets by calculate the groccary items please help me

Dani AI

Generated

For : a grocery calculator is simple in concept but there are a few practical points to avoid wasting time. Applets were once common, but browser support for in‑page Java applets is effectively gone and running them today requires special setup or legacy environments. Prefer a small desktop GUI (Swing or JavaFX) or a web page with JavaScript unless you must learn applets for a class.

Start with a tiny spec: each grocery row needs item name, unit price and quantity; the app computes subtotal, tax, discounts and total. Build a clear separation: a plain data model (an Item class using BigDecimal for money) and a UI that only reads/writes that model. Use a table UI (JTable) or dynamic rows, provide Add/Remove and a Calculate action, and keep input validation in one place.

Calculation and UI tips that save hours:

  • Use BigDecimal for all money math and apply setScale(2, RoundingMode.HALF_EVEN) (or HALF_UP if you prefer) before display.
  • Format results with NumberFormat.getCurrencyInstance() so values show correctly for the locale.
  • Reduce parse errors with JFormattedTextField/NumberFormatter in Swing, or validate inputs with try/catch and clear messages.
  • Keep business logic testable: write small unit tests for subtotal/tax/discount rules to catch rounding bugs.

Per , search for tutorials on GUI layout, event handling and number formatting. Per , an applet needs the usual lifecycle methods (e.g. init(), start()) if you still go that route — but expect signing/security hurdles and limited browser support. Start by implementing the calculation logic first, then wire a minimal UI and expand.

Recommended Answers

All 2 Replies

have you tried google?

commented: Thanks for reporting. +11

um extends applet is the first thing you want to do other than that... look up google for the rest and come back when you got a problem that we can specify to help you out in

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.