• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

error: cannot find symbol

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello.

I am currently attempting to create a program that uses the method 'waitNSeconds' to wait a different number of seconds before displaying the number of each different bank note, displayed at the bottom of the program, but when trying to compile the program I keep getting the error 'cannot find symbol' on the line 'wait1second' in my for loop.

Here's what I have so far:

public class BankTeller1
{

public static void waitNSeconds(int number)
{
int i;
for (i = 0; i < number; i++)
{
wait1second();
}
}

public static void main (String args[])
{
// declare and initialise variables
int Sterling = 77;
String indent = " ";
int Hundreds, Fifties, Twenties, Tens, Fives,Ones;

// Convert sterling amount into a working number of pounds
Ones = Sterling;

// perform calculations

// How many hundreds?
Hundreds = Ones / 100;

// Carry forward whatever is left
Ones = Ones % 100;

// How many fifties?
Fifties = Ones / 50;

// Carry forward whatever is left
Ones = Ones % 50;

// How many twenties?
Twenties = Ones / 20;

// Carry forward, and so on
Ones = Ones % 20;

Tens = Ones / 10;
Ones = Ones % 10;

// How many fives?
Fives = Ones / 5;

// Carry forward, and so on
Ones = Ones % 5;

// output results
System.out.println("The notes are :");
System.out.println();
System.out.println(indent + "Fifties : " + Fifties);
System.out.println(indent + "Twenties : " + Twenties );
System.out.println(indent + "Tens : " + Tens );
System.out.println(indent + "One pound coins :" + Ones);
System.out.println();
System.out.println("Total: " + Sterling + " pounds");

}
}


Any help/advice would be greatly appreciated.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
do you have a method defined somewhere named "wait1second()"? There certainly isn't one here in the code you posted.
 
Hayles Berry
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

fred rosenberger wrote:do you have a method defined somewhere named "wait1second()"? There certainly isn't one here in the code you posted.



Not at the moment, no. ^^;;

I wasn't entirely certain on how to define one.
 
Hayles Berry
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, I've managed to include a 'wait1second' method which seems to have helped with the "error: cannot find symbol" problem.

I just can't seem to work out how to call the 'waitNSeconds' method, so that it waits a specific length of time before displaying each piece of information.
 
Marshal
Posts: 79177
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch
I can give you a hint:There are methods which suspend execution, eg Thread#sleep, but that take milliseconds as its parameter. The best way to turn seconds to milliseconds is probably via the TimeUnit enumeration.
Don’t write wait1Second(), wait2Seconds(), wait3Seconds() etc.
 
Hayles Berry
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's okay, I've got it working now.

But thanks for the tips anyway, guys.
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well done. How did you do it?
 
reply
    Bookmark Topic Watch Topic
  • New Topic