Cannot Find Symbol (Java)?
-
When I compile my program, it says the error occurred on Line 70, which is this: Television bigScreen = new Television("Toshiba", 55); What am I doing wrong? import java.util.Scanner; /** * COSC 1436 Lab 8 * TelevisionDemo.java * Purpose: This class serves to demonstrate the Television class you will write * @author Dr. Tim McGuire * @author (your name here) * @version 1.0 (today's date here) */ public class TelevisionDemo { String MANUFACTURER; //Holds the brand name. This is a constant. int SCREEN_SIZE; //Holds the size of the television screen. This is a constant. boolean powerOn; //Holds the value 'True' if the power is On and 'False' if the power is Off. int channel; //Holds the value of the station that the television is showing. int volume; //Holds a number representing the loudness (0 being no sound). public int getVolume(int volume) { return volume; } public int getChannel(int channel) { return channel; } public String getManufacturer(String MANUFACTURER) { return MANUFACTURER; } public int getScreenSize(int SCREEN_SIZE) { return SCREEN_SIZE; } //Mutator for channel. public int setChannel(int channel) { channel = 2; return channel;} //Mutator for power. public void powerOn(boolean powerOn) { powerOn = !powerOn; } //Mutator to increase volume. public int increaseVolume(int volume) { volume = +1; return volume; } //Mutator to decrease volume. public int decreaseVolume(int volume) { volume = -1; return volume; } //This parameter brings in information. public void LucVincentTelevision(String MANUFACTURER, int SCREEN_SIZE) { channel = 2; volume = 20; powerOn = false; } public static void main(String[] args) { //create a Scanner object to read from the keyboard Scanner keyboard = new Scanner (System.in); //declare variables int station; //the user’s channel choice //declare and instantiate a television object Television bigScreen = new Television("Toshiba", 55); //turn the power on bigScreen.power(); //display the state of the television System.out.println("A " + bigScreen.getScreenSize() + " inch " + bigScreen.getManufacturer() + " has been turned on."); //prompt the user for input and store into station System.out.print("What channel do you want? "); station = keyboard.nextInt(); //change the channel on the television bigScreen.setChannel(station); //increase the volume of the television bigScreen.increaseVolume(); //display the the current channel and volume of the television System.out.println("Channel: " + bigScreen.getChannel() + " Volume: " + bigScreen.getVolume()); System.out.println("Too loud!! I am lowering the volume."); //decrease the volume of the television bigScreen.decreaseVolume(); bigScreen.decreaseVolume(); bigScreen.decreaseVolume(); bigScreen.decreaseVolume(); bigScreen.decreaseVolume(); bigScreen.decreaseVolume(); //display the current channel and volume of the television System.out.println("Channel: " + bigScreen.getChannel() + " Volume: " + bigScreen.getVolume()); System.out.println(); //for a blank line //HERE IS WHERE YOU WILL INSERT YOUR CODE TO PERFORM TASK #5 } } EDIT #5 Okay so I eliminated The (SCREEN_SIZE) and got less errors. I did it all for the ACCESSOR methods and MUTATORS and now have only 1 error. The error I still have remaining is: cannot find symbol bigScreen.power(); ^^^ //The purpose of this class is to modify a television. //@author Vince Luc //@date 3/26/2012 public class Television { String MANUFACTURER; //Holds the brand name. This is a constant. int SCREEN_SIZE; //Holds the size of the television screen. This is a constant. boolean powerOn; //Holds the value 'True' if the power is On and 'False' if the power is Off. int channel; //Holds the value of the station that the television is showing. int volume; //Holds a number representing the loudness (0 being no sound). //Accessor method getVolume. public int getVolume() { return volume; } //Accessor method getChannel. public int getChannel() { return channel; } //Accessor method getManufacturer. public String getManufactu EDIT #5 Okay so I eliminated The (SCREEN_SIZE) and got less errors. I did it all for the ACCESSOR methods and MUTATORS and now have only 1 error. The error I still have remaining is: cannot find symbol bigScreen.power(); ^^^ //The purpose of this class is to modify a television. //@author Vince Luc //@date 3/26/2012 public class Television { String MANUFACTURER; //Holds the brand name. This is a constant. int SCREEN_SIZE; //Holds the size of the television screen. This is a constant. boolean powerOn; //Holds the value 'True' if the power is On and 'False' if the power is Off. int channel; //Holds the value of the station that the television is showing. int volume; //Holds a number representing the loudness (0 being no sound). //Accessor method getVolume. public int getVolume() { return volume; } //Accessor method getChannel. public int getChannel() { return channel; } //Accessor method getManufacturer. public String getManufactu
-
Answer:
The TelevisionDemo class can't find the Television class. It means that if the Television class exists, it's not currently available to the TelevisionDemo class. Assuming the Television class exists and is public: There are two ways to make it available to TelevisionDemo: – Make sure they're in the same folder. Then TelevisionDemo will be able to find the Television class. – Or, if you've learned about packages, you could store Television in a package and import it to the TelevisionDemo class. ——————————————— EDIT: I think the error is one of these: – Does Television.class exist? If Television.java exists, but Television.class doesn't, you should compile Television.java first. – Are Television.class and TelevisionDemo.class in the same folder? Make sure they're in the same folder. ——————————————— EDIT(2): "... cannot be applied to given types" means that you're using the wrong parameters. You should use the same as the ones you wrote in Television.java. If it says someMethod(int n), you have to put an int between the brackets. For instance: bigScreen.someMethod(24); If it says someMethod(), put nothing between the brackets. Like this: bigScreen.someMethod(); etc. Example: Maybe you made a method: decreaseVolume(int n) but when calling it, you call it like this: bigScreen.decreaseVolume(); NOTE: The error may possibly be in Television.java. You should check if the methods have the right parameters. You could also add the exact error message on here if you are unable to solve the problem. Then I'll know which method it happens to. ——————————————— EDIT(3): It doesn't seem like Television has a method called power(). Maybe you named it something else, or maybe you didn't make it at all. Also, when you made the method getScreenSize(), you gave it some kind of parameter. You may have written getScreenSize(int SCREEN_SIZE) when you were supposed to write getScreenSize(). You should open Television.java and remove that parameter. ——————————————— EDIT(4): Television has no method called power(). You may have called it powerOn or getPower, if you made it at all. By the way, your code was too large to be pasted. You could paste your code on here: http://pastebin.com and add the link as additional details. Feel free to add additional details to your question if you need further help.
Vincent at Yahoo! Answers Visit the source
Other answers
The TelevisionDemo class can't find the Television class. It means that if the Television class exists, it's not currently available to the TelevisionDemo class. Assuming the Television class exists and is public: There are two ways to make it available to TelevisionDemo: – Make sure they're in the same folder. Then TelevisionDemo will be able to find the Television class. – Or, if you've learned about packages, you could store Television in a package and import it to the TelevisionDemo class. ——————————————— EDIT: I think the error is one of these: – Does Television.class exist? If Television.java exists, but Television.class doesn't, you should compile Television.java first. – Are Television.class and TelevisionDemo.class in the same folder? Make sure they're in the same folder. ——————————————— EDIT(2): "... cannot be applied to given types" means that you're using the wrong parameters. You should use the same as the ones you wrote in Television.java. If it says someMethod(int n), you have to put an int between the brackets. For instance: bigScreen.someMethod(24); If it says someMethod(), put nothing between the brackets. Like this: bigScreen.someMethod(); etc. Example: Maybe you made a method: decreaseVolume(int n) but when calling it, you call it like this: bigScreen.decreaseVolume(); NOTE: The error may possibly be in Television.java. You should check if the methods have the right parameters. You could also add the exact error message on here if you are unable to solve the problem. Then I'll know which method it happens to. ——————————————— EDIT(3): It doesn't seem like Television has a method called power(). Maybe you named it something else, or maybe you didn't make it at all. Also, when you made the method getScreenSize(), you gave it some kind of parameter. You may have written getScreenSize(int SCREEN_SIZE) when you were supposed to write getScreenSize(). You should open Television.java and remove that parameter. ——————————————— EDIT(4): Television has no method called power(). You may have called it powerOn or getPower, if you made it at all. By the way, your code was too large to be pasted. You could paste your code on here: http://pastebin.com and add the link as additional details. Feel free to add additional details to your question if you need further help.
Unern
Hi Vincent, Line 70 is failing because you are referencing the class Television, without declaring it. You would either need to create another java class Television.java with a constructor accepting a String and an int, or define an inner class to do this. Hope this helps!
John
Hi Vincent, Line 70 is failing because you are referencing the class Television, without declaring it. You would either need to create another java class Television.java with a constructor accepting a String and an int, or define an inner class to do this. Hope this helps!
John
So what ewxactly is the error message you get ?
June
Related Q & A:
- How to Implement Gateway Service something similar to Oracle API gateway Using Java and Java based Open Source frameworks only?Best solution by Quora
- What is the ticker symbol for alibaba?Best solution by Yahoo! Answers
- How do I get the Trademark symbol in my name on MSN messenger?Best solution by Yahoo! Answers
- Difference between Java 2 and Java 6?Best solution by Yahoo! Answers
- Why are there some planes that have a Flag or national symbol on the rudder along with the Fuselage symbol?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.