I have a java code that i don't know what is the problem. could you help me? On"Stock testStock = new Stock();" I get an error message that says " Stockcannot be resolved to a type."

import java.util.Scanner;

/**
An application class to test Stock class
*/
public class StockTesting
{
public static void main (String[] args)
    {
    //Create an object belonging to the class Stock
    Stock testStock = new Stock();
    //Declare local variables
    int inputNumberOfShares, outputNumberOfShares;
    String inputTickerSymbol, outputTickerSymbol;
    double inputDividend, outputDividend;
    double outputYearlyDividend;
    //Get input values
    Scanner scannedInfo = new Scanner(System.in);
    System.out.print("Enter numbers own, stock symbol"
    + " and dividend : ");
    System.out.flush();
    inputNumberOfShares = scannedInfo.nextInt();
    inputTickerSymbol = scannedInfo.next();
    inputDividend = scannedInfo.nextDouble();
    System.out.println();
    //Test mutator and accessor methods
    testStock.setNumberOfShares(inputNumberOfShares);
    testStock.setTickerSymbol(inputTickerSymbol);
    testStock.setDividend(inputDividend);
    outputNumberOfShares
    = testStock.getNumberOfShares ();
    outputTickerSymbol = testStock.getTickerSymbol();
    outputDividend = testStock.getDividend();
    System.out.println("Number of shares : " +
    outputNumberOfShares);
    System.out.println("Stock symbol is : " +
    outputTickerSymbol);
    System.out.println("Dividend per share is : " +
    outputDividend);
    //Test yearlyDividend method
    outputYearlyDividend = testStock.yearlyDividend();
    System.out.println("Yearly Dividend is : " +
    outputYearlyDividend);
    System.out.println();
    //Test mutator and accessor methods
    testStock.setNumberOfShares(inputNumberOfShares);
    testStock.setTickerSymbol(inputTickerSymbol);
    testStock.setDividend(inputDividend);
    outputNumberOfShares
    = testStock.getNumberOfShares ();
    outputTickerSymbol = testStock.getTickerSymbol();
    outputDividend = testStock.getDividend();
    System.out.println("Number of shares : " +
    outputNumberOfShares);
    System.out.println("Stock symbol is : " +
    outputTickerSymbol);
    System.out.println("Dividend per share is : " +
    outputDividend);
    //Test yearlyDividend method
    outputYearlyDividend = testStock.yearlyDividend();
    System.out.println("Yearly Dividend is : " +
    outputYearlyDividend);
    System.out.println(testStock.toString());
    }
}

The code you posted is for a class called StockTesting. Is there a class called Stock? Where is the code for that class?
ps Please post code in CODE tags, it's completely unreadable without them.

The reason you are getting type resolve issues is because most likely you did not create the Stock class. Here's a pregenerated one you can use from Eclipse: (You'll have to set the parameters yourself.)

public class Stock
{
	private int NumberOfShares;
	private String TickerSymbol;
	private double Dividend;
	
	public Stock()
	{
		NumberOfShares = 0;
		TickerSymbol = "none";
		Dividend = 0.0;
	}

	public void setNumberOfShares(int inputNumberOfShares)
	{
		// TODO Auto-generated method stub
		NumberOfShares = inputNumberOfShares;
	}

	public void setTickerSymbol(String inputTickerSymbol)
	{
		// TODO Auto-generated method stub
		TickerSymbol = inputTickerSymbol;
	}

	public void setDividend(double inputDividend)
	{
		// TODO Auto-generated method stub
		Dividend = inputDividend;
	}

	public int getNumberOfShares()
	{
		// TODO Auto-generated method stub
		return NumberOfShares;
	}

	public String getTickerSymbol()
	{
		// TODO Auto-generated method stub
		return TickerSymbol;
	}

	public double getDividend()
	{
		// TODO Auto-generated method stub
		return Dividend;
	}

	public double getYearlyDividend()
	{
		// TODO Auto-generated method stub
		return 0;
	}

}
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.