Main Method no defined

This is not homework, just additional practice

Page 1 of 1

5 Replies - 674 Views - Last Post: 30 March 2009 - 11:57 PM Rate Topic: -----

#1 mobius4139  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 118
  • Joined: 24-March 09

Main Method no defined

Posted 30 March 2009 - 02:58 AM

I have written this code to serve as an invoice at a hardware store. It gets the Part Number, Description, Cost, and Quantity purchased and then calculates the cost * Quantity for the total. When debug it in Netbeans it works however, when I try and compile it in Terminal I get an error message 'main method not defined'

any ideas on what I'm doing wrong? Thanks

~B

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package problem313;

/**
 *
 * @author TheGales
 */
public class Problem313
{
	  
	/**
	 * @param args the command line arguments
	 */

		// TODO code application logic here
	private String partNumber;
	private String partDescription;
	private int partQuantity;
	private double partCost;
	private double invoiceAmount;
	private double total;
	private double x = partCost;
	private int y = partQuantity;

	public void setTotal(double partCost, int partQuantity)
	{
		total = partCost * partQuantity;
	}
	public double getTotal()
	{
		return total;
	}


	public void setPartNumber (String newNumber)
	{
		partNumber = newNumber; // store part number
	}
		public String getPartNumber ()
	{
		return partNumber;
	}


	public void setPartDescription (String newDescription)
	{
		partDescription = newDescription;
	}
	public String getPartDescription()
	{
		return partDescription;
	}


	public void setPartQuantity(int newQuantity)
	{
		partQuantity = newQuantity;// store part quantity
	}
	public int getPartQuantity()
	{
		if (partQuantity <=0 )
			return (partQuantity = 0);
		else
			return partQuantity;
	}


	public void setPartCost(double newCost)
	{
		partCost = newCost;
	}
		public double getPartCost()
		{
		if (partCost <=0)
			return (partCost = 0);
		else
			return partCost;
		}
		
	//display an invoice message
	public void displayMessage()
	{
		System.out.println("Welcome to the Hardware Invoice");
	}

	public void displaygetInvoiceAmount()
	{
	   invoiceAmount = (partCost * partQuantity);
	   System.out.printf("Invoice Total: "+ invoiceAmount);

	}// end of method
}//end of class




here is the rest of the code

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package problem313;

import java.util.Scanner;

/**
 *
 * @author TheGales
 */
public class Problem313Test
{
	private static String partNumber;
	private static String newNumber;
	private static String partDescription;
	private static String newCost;
	private static String partQuantity;
	private static String newQuantity;
	private static String partCost;

	public static void Problem313 (String args[])
	{

		Problem313 invoice = new Problem313();

		Scanner input = new Scanner (System.in);//

		System.out.println("Welcome to Hardware invoice:");// intro to invoice



		System.out.println("Enter Part Number: "); //Prompt user to input part number data
		partNumber = input.nextLine();
		invoice.setPartNumber(newNumber);
		System.out.println();

		System.out.println("Enter Part Descripiton: "); //Prompt user to input part description data
		partDescription = input.nextLine();
		invoice.setPartNumber(newCost);
		System.out.println();

		System.out.println("Enter Part Quantity: "); //Prompt user to input part numebr data
		partQuantity = input.nextLine();
		invoice.setPartNumber(newQuantity);
		System.out.println();

		System.out.println("Enter Part Cost: "); //Prompt user to input part numebr data
		partCost = input.nextLine();
		invoice.setPartNumber(newCost);
		System.out.println();

		invoice.displayMessage();
		invoice.displaygetInvoiceAmount();

	}
}




Is This A Good Question/Topic? 0
  • +

Replies To: Main Method no defined

#2 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: Main Method no defined

Posted 30 March 2009 - 03:07 AM

In
public class Problem313Test
change
public static void Problem313 (String args[])
to
public static void main (String args[])

This post has been edited by n8wxs: 30 March 2009 - 03:09 AM

Was This Post Helpful? 0
  • +
  • -

#3 mobius4139  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 118
  • Joined: 24-March 09

Re: Main Method no defined

Posted 30 March 2009 - 03:25 AM

Thanks I'll give it a shot. i didn't even see that when I skimmed over it. I think I just spent too much time staring at it and needed some fresh eyes to check it out.

~B
Was This Post Helpful? 0
  • +
  • -

#4 mobius4139  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 118
  • Joined: 24-March 09

Re: Main Method no defined

Posted 30 March 2009 - 05:11 PM

that worked to solve the main class missing problem but it revealed a new problem.
The user enters Product Number ~ Product Description ~ Product Quantity ~ Product Cost

Then the output is supposed to multiply Product Quantity * Product Cost and provide the appropriate data.

However, I keep getting the output of Invoice Total: 0.0

I can't figure out where I am going wrong. I have tried creating a total = poductCost * productQuantity but then I receive an error of
incompatable types found: java.lang.string
required: int


the problem is that I am not using a string I am using a double and an int


Any help would be appreciated. Thanks!

~B
Was This Post Helpful? 0
  • +
  • -

#5 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: Main Method no defined

Posted 30 March 2009 - 05:26 PM

You are calling the same method:
System.out.println("Enter Part Number: "); //Prompt user to input part number data
partNumber = input.nextLine();
invoice.setPartNumber(newNumber);  // ok, it's a part number
System.out.println();

System.out.println("Enter Part Descripiton: "); //Prompt user to input part description data
partDescription = input.nextLine();
invoice.setPartNumber(newCost);   <<<<<<<<<<<<<<<<<<<<<<<<
System.out.println();

System.out.println("Enter Part Quantity: "); //Prompt user to input part numebr data
partQuantity = input.nextLine();
invoice.setPartNumber(newQuantity);   <<<<<<<<<<<<<<<<<<<<<<<<
System.out.println();

System.out.println("Enter Part Cost: "); //Prompt user to input part numebr data
partCost = input.nextLine();
invoice.setPartNumber(newCost);   <<<<<<<<<<<<<<<<<<<<<<<<
System.out.println();


This post has been edited by n8wxs: 30 March 2009 - 05:28 PM

Was This Post Helpful? 1
  • +
  • -

#6 mobius4139  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 118
  • Joined: 24-March 09

Re: Main Method no defined

Posted 30 March 2009 - 11:57 PM

Wow,

I was really tired when I wrote this and I must have zoned out. Thanks for the help! I'll have to wait til I get home to check this out but I'm pretty sure that this is the problem. Thanks a bunch!

~B
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1