* Java / Keyboard class, neophyte stumped
@ 2001-10-06 13:29 Chuck
2001-10-06 14:19 ` me
2001-10-06 18:23 ` Jeffrey Carter
0 siblings, 2 replies; 3+ messages in thread
From: Chuck @ 2001-10-06 13:29 UTC (permalink / raw)
I am tryin to use the Keyboard class included
in a book by John Lewis. I get the following
error messages:
C:\MyJava\EvenNumber.java:9: cannot resolve symbol
symbol : class keyboard
location: package cs1
import cs1.keyboard;
^
C:\MyJava\EvenNumber.java:26: cannot resolve symbol
symbol : variable keyboard
location: class EvenNumber
num = keyboard.readInt();
^
2 errors
Here is my code:
import cs1.keyboard;
import java.io.*;
public class EvenNumber
{
public static void main (String[] args)
{
int num=0;
int sum=0;
int test=0;
// keyboard input
System.out.println ("Input any integer over the value of 2: ");
System.out.println (" ");
num = keyboard.readInt();
while (test == 0) //loop to repeat test for >2 condition
{
if (num < 2) //Test to determine if the number is over 2
{
System.out.println ("The number you entered was less than 2");
System.out.println ("Please enter another integer: ");
// num = Keyboard.readInt();
test = 0;
}
else
test = 1;
}
// loop to add all even integers
for (int i=0; i<=num; i=i+2)
{
sum=sum+i;
}
// print out results
System.out.println ("The sum of all even integers between");
System.out.println ("2 and your integer, "+ num + ", is: " + sum);
System.out.println (" ");
}
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Java / Keyboard class, neophyte stumped
2001-10-06 13:29 Java / Keyboard class, neophyte stumped Chuck
@ 2001-10-06 14:19 ` me
2001-10-06 18:23 ` Jeffrey Carter
1 sibling, 0 replies; 3+ messages in thread
From: me @ 2001-10-06 14:19 UTC (permalink / raw)
You do know about classpath in java, right?
and btw, Ada is not java, it is a different language. so this question
is send to the wrong group.
In article <7b4af09f.0110060529.368829c8@posting.google.com>,
the_edwards@ameritech.net says...
>
>I am tryin to use the Keyboard class included
>in a book by John Lewis. I get the following
>error messages:
>C:\MyJava\EvenNumber.java:9: cannot resolve symbol
>symbol : class keyboard
>location: package cs1
>import cs1.keyboard;
> ^
>C:\MyJava\EvenNumber.java:26: cannot resolve symbol
>symbol : variable keyboard
>location: class EvenNumber
> num = keyboard.readInt();
> ^
>2 errors
>
>
>Here is my code:
>
>import cs1.keyboard;
>import java.io.*;
>
>
>public class EvenNumber
>{
>
> public static void main (String[] args)
>
> {
> int num=0;
> int sum=0;
> int test=0;
>
> // keyboard input
> System.out.println ("Input any integer over the value of 2: ");
> System.out.println (" ");
> num = keyboard.readInt();
>
> while (test == 0) //loop to repeat test for >2 condition
> {
>
> if (num < 2) //Test to determine if the number is over 2
> {
> System.out.println ("The number you entered was less than 2");
> System.out.println ("Please enter another integer: ");
> // num = Keyboard.readInt();
> test = 0;
> }
> else
> test = 1;
>
> }
>
>
>
> // loop to add all even integers
> for (int i=0; i<=num; i=i+2)
> {
> sum=sum+i;
> }
> // print out results
> System.out.println ("The sum of all even integers between");
> System.out.println ("2 and your integer, "+ num + ", is: " + sum);
> System.out.println (" ");
>
>
> }
>}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Java / Keyboard class, neophyte stumped
2001-10-06 13:29 Java / Keyboard class, neophyte stumped Chuck
2001-10-06 14:19 ` me
@ 2001-10-06 18:23 ` Jeffrey Carter
1 sibling, 0 replies; 3+ messages in thread
From: Jeffrey Carter @ 2001-10-06 18:23 UTC (permalink / raw)
Using GNAT 3.13p/Win98 on your code, I get
C:\Code>gcc -c evennumber.adb
evennumber.adb:1:01: compilation unit expected
evennumber.adb:6:01: illegal character, replaced by "("
evennumber.adb:8:40: illegal character, replaced by "("
evennumber.adb:10:09: illegal character, replaced by "("
evennumber.adb:20:29: == should be =
evennumber.adb:21:17: illegal character, replaced by "("
evennumber.adb:24:33: illegal character, replaced by "("
evennumber.adb:25:88: missing string quote
evennumber.adb:26:13: missing string quote
evennumber.adb:27:82: missing string quote
evennumber.adb:28:11: missing string quote
evennumber.adb:31:33: illegal character, replaced by ")"
evennumber.adb:35:17: illegal character, replaced by ")"
evennumber.adb:41:25: illegal character, replaced by "("
evennumber.adb:43:25: illegal character, replaced by ")"
evennumber.adb:50:09: illegal character, replaced by ")"
evennumber.adb:51:01: illegal character, replaced by ")"
Perhaps you need to spend more time with your Ada
textbook/instructor/tutorial before trying something this ambitious? :)
--
Jeff Carter
"Nobody expects the Spanish Inquisition!"
Monty Python's Flying Circus
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-10-06 18:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-06 13:29 Java / Keyboard class, neophyte stumped Chuck
2001-10-06 14:19 ` me
2001-10-06 18:23 ` Jeffrey Carter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox