January 31st, 2008 at 09:59am
Under Forum
Having trouble compiling. What am I doing wrong?
/* method accepts parameters (array, max and min) and returns count
* of how many integers fall between max and min.
*/
import java.util.*;
import java.io.*;
public class RangeCount2{
public static final int Length = 10;
public static void main (String [] args){
Scanner console = new Scanner(System.in);
Scanner input = getInfo(console);
processFile(input);
Scanner num = new Scanner(System.in);
System.out.print(“Maximum Number: “);
int max = console.nextInt();
System.out.print(“Minimum Number: “);
int min = console.nextInt();
}
public static Scanner getInfo(Scanner console){
Scanner input = null;
while (input == null){
System.out.print(“input file name? “);
String name = console.nextLine();
try {
input = new Scanner(new File(name));
} catch (FileNotFoundException e) {
System.out.println(“File not found. Please try again.”);
}
}
return input;
}
public static void processFile(Scanner input){
int[] Array = new int [Length];
while (input.hasNextLine()){
String text = input.nextLine();
int[] Array1 = transferFrom(text);
}
}
public static int[] transferFrom(String text){
Scanner data = new Scanner (text);
int[] result = new int [Length];
int i = 0;
while (data.hasNextInt()){
result[i] = data.nextInt();
i++;
}
countInRange(result, max, min);;
}
public static void countInRange (int[] result, int max, int min){
int count = 0;
for (int x : result) {
if (x <= max && x >= min){
count++;
}
}
System.out.println(“There is/ are ” + count + ” elements whose values fall”);
System.out.println(“between ” + min + ” and ” + max + “.”);
}
}
Compile error:
RangeCount2.java:60: cannot find symbol
symbol : variable max
location: class RangeCount2
countInRange(result, max, min);;
^
RangeCount2.java:60: cannot find symbol
symbol : variable min
location: class RangeCount2
countInRange(result, max, min);;
^
2 errors
Tool completed with exit code 1
Best answer:
Twice you’re referencing a variable called “max” without having defined such a variable.
You did define a variable called “max” in your main() method, but it’s just a local variable; it doesn’t exist outside the context of main().
Since all your methods are static (and you therefore can’t use instance variables) you probably want to ask the user for min and max before you process the file (you’ve got it the other way around in your main() method) then pass those values to the other functions as parameters.
By Barcode Scanner
July 15th, 2007 at 05:21pm
Under Forum
Im having “cannot find symbol errors” in my java program. Its in two lines. Can someone take a look?
The errors occur in lines 1 and 7. I thinks its a problem with scanner. Can anyone clarify what I need to change so I can make this program compile?
import java.util.scanner;
public class Program6
{
public static void main(String[] args){
int n = 0;
Scanner scan = new Scanner(System.in);
double x = scan.nextDouble();
System.out.println(“Enter several ints, push D twice + to \
exit”);
while (n <= 100) { // Test and Loop
System.out.println(n);
n = n + 1;
}
}
}
Best answer:
I think you should write: import java.util.Scanner;
instead of: import java.util.scanner;
(s->S)
By Barcode Scanner
January 26th, 2007 at 08:57am
Under Forum
Why am I having such a hard time adding barcodes to the Key Ring app on my HTC Incredible?
I just can’t get them to scan and I can’t figure out why. Am I supposed to press something? Is the camera just being finicky?
Best answer:
Try the CardStar app, might work better for you.
By Barcode Scanner
June 16th, 2006 at 05:37am
Under Forum
Having Problems With My Wireless Signal?
I have no idea whats going on with my wireless signal. . . Could it be because of my Police Scanner? Can a police scanner interfere with wireless signals? I tried changing my Wireless Channel, but that didn’t work either. That only made my wireless computer stop connecting.
Best answer:
make sure that there is no Micorwave, Cordless Phones and / or any kind of device working with different sorts of Electro-Magnetic Waves near by the router.
By Barcode Scanner
June 26th, 2005 at 07:33pm
Under Forum
Help!My Boyfriend is having trouble with his vision cause of reflecting laser scanner that he was scanning w?
He was scanning some items at the grocery store and the reflection of the scanner must have went into his eye. He is having trouble seeing and has constant moving static looking stuff in his eyes! Need info on this or website on injuries do to this and what to do besides go to doctor.
Thank you
Best answer:
There is nothing else to do other than go to a doctor. There is no way to diagnose a patient with just 4 lines of text explaining the problem. A doctor needs to physically see the patient to give any type of reasonable diagnosis or advice. Go see a doctor! This could be anything from no problem at all to irreversible eye damage. But only a doctor can tell. The store should pay for this, as it is an on the job injury (if he is an employee).
However, there is little chance that both eyes would be damaged. You say ‘there is static stuff in his eyes’. Does that mean you can see something? And can you see it in both eyes? If so, that doesn’t make much sense. Something else is going on. It would most likely be just one eye that was affected. Furthermore, you probably wont be able to see it, as the damage will occur on the retina, which is the backside of the eye. That is only visible when shining light in the patients eye. If it is on the front side of the eye (the part that’s blue or brown or white), then its probably something else.
If its not something you see, but its something HE sees, then it should also be in only one eye. If it is in both eyes, then it isnt an eye issue, its probably a neurologic issue, like a migrane headache, which can be triggered by looking at bright light. If it moves (in his vision) without his eye moving, then it almost certainly is neurology. Laser eye damage will usually be a blind spot in one eye.
Anyways, at the very least, call a doctor. If there is laser eye damage, the sooner you see a doctor, the better your chances for recovery. There really isnt much you can do by yourself.
By Barcode Scanner
Next Posts