• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Cannot find symbol variable

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I tried to compile my code, I get the error that my symbol variable cannot be found. Here is my code:

import java.util.Scanner;

public class DemoStudent
{

public static void main (String [] args)
{
//creating an instance of the DemoStudent class
std1 = new Student();
//std2 = new Student();
//std3 = new Student();

Scanner in = new Scanner(System.in);

//get first name & last name
System.out.println("Enter your first name.");
First = in.nextLine();
System.out.println("Enter your last name.");
Last = in.nextLine();

//get tuition amount
System.out.println("Enter full tuition amount.");
Tuition = in.nextLine();

std1.setFirst(first);
//std2.setFirst();
//std3.setFirst();
std1.setLast(last);
//std2.setLast();
//std3.setLast();
std1.setTuition(t);
//std2.setTuition();
//std3.setTuition();

printPayment(std1);
//printPayment(student2);
//printPayment(student3);

}

//This method expects to be passed a Student instance
//as an argument

//static void printPayment(Student std1);
{
//double paymt;
//Scanner scan = new Scanner(System.in);
//this method will accept a reference
//to a specific student
//System.out.println(std1.getFullName(std1));
//System.out.println("Current Tuition:" + std1.getTuition());


//accept payment
//System.out.println("Enter payment:");
//paymt = scan.nextDouble();
//std1.payTuition(paymt);
//System.out.println("Current Tuition:" + std1.getTuition());
}


{
//double paymt;
//Scanner scan = new Scanner(System.in);
//this method will accept a reference
//to a specific student
//System.out.println(std2.getFullName());
//System.out.println("Current Tuition:" + std2.getTuition());


//accept payment
//System.out.println("Enter payment:");
//paymt = scan.nextDouble();
//std1.payTuition(paymt);
//System.out.println("Current Tuition:" + std2.getTuition());
}

{
//double paymt;
//Scanner scan = new Scanner(System.in);
//this method will accept a reference
//to a specific student
//System.out.println(std3.getFullName());
//System.out.println("Current Tuition:" + std3.getTuition());


//accept payment
//System.out.println("Enter payment:");
//paymt = scan.nextDouble();
//std1.payTuition(paymt);
//System.out.println("Current Tuition:" + std3.getTuition());
}

}
 
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yolanda!... Welcome to Javaranch,
This is webservices forum, I am moving your question to Java in General (beginner) forum for better responses.
Have a nice time here.
Balaji
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is more to the 1st compile error...



i.e., cannot find symbol
symbol: variable std1


std1 isn't declared.

Student std1 = new Student();


... then on to the next compile error.
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Yolanda,

I was able to fix 8 errors, 4 are still remaining,plz copy&paste this code(fixed parts are in bold) and run javac compiler...




compiler will report 4 errors because you didn't write 4 methods and you are trying to use them; you have to write methods before you can pass something to them.The same goes to variables,if you want to use variable first you have to declare it and then you can initialize it for example:





I suggest you reading some introductory text about using variables in Java before you actually start programming and also take some short example first with 2-3 variables and only 1 method,after you fully understand that short example move on to more complicated examples,using many variables and many methods.




kind regards
Igor
[ February 21, 2005: Message edited by: Igor Stojanovic ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic