Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
import java.util.*;
import java.io.*;

public class Order {
   private String OrderNumber;
   private double ItemPrice;
   private int Quantity;
   static int selection;
   double Total;
   
    public void setOrderNumber(String OrderNo)
    {
         OrderNumber = OrderNo;
    }      

    public void setItemPrice(double Price)
    {
         ItemPrice = Price;
    }      

    public void setQuantity(int Qnty)
    {
         Quantity = Qnty;
    }        

    public String getOrderNumber()
    {
         return OrderNumber;
    }
    
    public double getItemPrice()
    {
         return ItemPrice;
    }

    public int getQuantity()
    {
         return Quantity;
    }    

    Order(String OrderNo, double Price, int Qnty)
    {
      OrderNumber = OrderNo;
      ItemPrice = Price; 
      Quantity = Qnty; 
    }
    
    public double ComputeTotal(double ItemPrice, int Quantity)
    {
      Total = (ItemPrice * Quantity)+ 0.12;
      return Total;
    }
    
    public void displayOrderDetails()
    {
      System.out.println("Order Number:"+ OrderNumber);
      System.out.println("ItemPrice:"+ ItemPrice);
      System.out.println("Quantity"+ Quantity);
    }
}


What I have tried:

it gives me this error please help {Error: Main method not found in class Order, please define the main method as:    public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application}
Posted
Updated 10-Mar-22 0:49am

Every Java apps has a starting point: a method that the system calls when your app starts. This has a specific name and signature, and your code doesn't contain it:
Java
public class MyClass {
	public static void main(String[] args) {
		System.out.println("Hello World");
	}
}
Add the main method to your class, and have it call your other methods as necessary.
 
Share this answer
 
Comments
CPallini 10-Mar-22 4:12am    
5.
In addition to Griff's advice, see this Java Tutorial[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900