Cant find method? and i cant figure out how to round a decimal....
when i compile this it says "getAverage not found in class AverageGradeUser" - look at actionPeformed() to find where its used at....how do i fix this, i had it working but somehow messed it up and when the new average is figured and put in the results textfield, how can u round it off to the nearest tenth (0.1)..ive tried using NumberFormat and related things but couldnt get it to work
please help me
thanks
p.s. keep in mind i am a rookie-rookie-rookie in java programming
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class AverageGradeUser extends Applet implements ActionListener
/****InstanceVariables****/
public TextField input;
/*****InitMethod****/
public void init()
Label directions = new Label("Enter a grade percent: ");
input = new TextField(10);
Label results = new Label("Your new average is: ");
TextField output = new TextField(10);
add(directions);
add(input);
add(results);
add(output);
output.setEditable(false);
input.addActionListener(this);
} // init()
public void actionPerformed(ActionEvent e)
double grade = Double.parseDouble(input.getText());
if (e.getSource() == input)
getAverage(grade);
} // actionPerformed()
} // AverageGradeUser class
============================================================
(the classes are in separate files but both are in the project)
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class AverageGrade
/****InstanceVariables****/
private double total = 0;
private double counter = 0;
private double average = 0;
private TextField input;
private TextField output;
/****ConstructorMethod****/
public AverageGrade()
/****AccessMethod****/
public void getAverage(double g)
total += g;
counter ++;
average = total / counter;
output.setText(average + " " + getLetterGrade(average));
input.setText("");
} // getAverage()
private String getLetterGrade(double avg)
if (avg >= 90)
return "A";
else if (avg >= 80)
return "B";
else if (avg >= 70)
return "C";
else if (avg >= 60)
return "D";
else if (avg < 60)
return "F";
else
return "error";
} // getLetterGrade()
} // AverageGrade class
According to the code you have posted, method "getAverage()" is defined in class "AverageGrade" -- and not in class "AverageGradeUser". Therefore, you have two choices (in my opinion):
1. Add the definition of method "getAverage()" to class "AverageGradeUser"
2. Change the "actionPerformed()" method:
Replace the line:
getAverage(grade)with
new AverageGrade().getAverage(grade)Hope this helps you.
Good Luck,
Avi.
Similar Messages
-
My mini died. bought one used from a friend... all of my songs and books are on my iPhone, and I cant figure out how to get them onto this new computer. this is frustrating. the things i really want are purchases I've made from itunes store... help
!!!!!Hey kevyg3,
I was able to find an article that I believe will help you move your iTunes purchases from your iPhone over to your new computer:
iTunes Store: Transferring purchases from your iOS device or iPod to a computer
http://support.apple.com/kb/HT1848
Hope this helps,
David -
i bought this off of my friend and now i cant figure out how to down load music onto it its and ipod shuffle
Hey kevyg3,
I was able to find an article that I believe will help you move your iTunes purchases from your iPhone over to your new computer:
iTunes Store: Transferring purchases from your iOS device or iPod to a computer
http://support.apple.com/kb/HT1848
Hope this helps,
David -
I just got my ipad and i cant figure out how to use it
i just got a new ipad and i cant figure out how to use it can u help me program it
You have to "activate" it with a computer having iTunes loaded. (Or have the apple store activate it for you)
You would connect the iPad to the computer's USB port with the supplied cable.
The itunes will walk you through the process with messages.
Then, you can explore and add music and apps with itunes or download them from the itunes store.
One way to get good training is to find someone with an iPhone or ipod touch and let them give you a few minutes of training.
Or take it to an apple store and ask for a quick demo.
You will catch on quick, fast and in a hurry.
Also, watch the videos on this web page: http://www.apple.com/ipad/ -
How do I update the iCloud ID on my phone? I changed my ID on my laptop, but my iphone still has "sign in to iCloud" with the wrong ID and I cant figure out how to change it.
I have same question
-
i have an ipod touch and i put cds on itunes onmy computer , but i cant figure out how to put the music from the cds on my ipod touch can anyone help me?
ok i select th e music from my music libary and go to file and click sync to my ipod and when it gets to step 3.. it says waiting for changes to be made.. yes the songs play on the itunes .. and no it wasnt the same computer i used last time
-
My mac is version 10.5.8 and I cant figure out how to up date it.
My friends mac is a version 10.5.8 and i cant figure out how to up date it. The last update says it was february of 2011...
The first step in Upgrading... is to Snow Leopard = OS X 10.6.x
It is Not available as a download... It is a Paid Upgrade.
Do this first...
Check that your Mac meets the System Requirements for Snow Leopard...
Snow Leopard Tech Specs
http://support.apple.com/kb/SP575
If so... Purchase a Snow Leopard Install Disc...
http://store.apple.com/us/product/MC573Z/A/mac-os-x-106-snow-leopard
Other countries...
http://support.apple.com/kb/HE57
After the Successful Install, run Software Update to get the latest updates for Snow Leopard.
Be sure to make a Backup of your Current System Before Upgrading... -
my lock button is jammed and i read somewhere that you can turn your phone on through itunes. i have tried plugging it up to a charger and doing everything you can imagine to get the button unjammed. i cant figure out how to use itunes to get it to turn on, any advice or know of another way?
maybe your power button is pushed down and won't allow it to turn on.
usually when you touch any button on an iphone, it will turn on. wether it's the home or power button.
you should take your phone into the apple store. -
Hi
Hi I just got my new Apple TV and I cant figure out how to connect it with My MacBook Air (11-inch, Late 2010- Processor 1.4 GHz Intel Core 2 Duo) OSX Version 10.8Are you referring to mirroring or you just unable to set up homesharing.
AirPlay Mirroring requires a second-generation Apple TV or later, OS X 10.8 or better and is supported on the following Mac models: iMac (Mid 2011 or newer), Mac mini (Mid 2011 or newer), MacBook Air (Mid 2011 or newer), and MacBook Pro (Early 2011 or newer). It also requires the computer to be using wi-fi. -
Help , i have cds on my laptop and i cant figure out how to put them on my iphone
help i have cds on my laptop and i cant figure out how to put them on my iphone
Sync them as described in the User's Guide.
-
i recently sold my iphone and it is locked so it cannot be used. cant figure out how to unlock it....can anyone help??
wilser01 wrote:
i recently sold my iphone and it is locked so it cannot be used. cant figure out how to unlock it....can anyone help??
Did you erase it before you sold it?
Settings> General > Reset - Erase all content & settings.
Or did you leave all your personal info on it and give it to someone else? -
I purchased a song off of itunes and it said it downloaded successfully, but when i try to listen to that song it only plays 2 seconds of that song and i cant figure out how to download that song again. What can i do.
Delete it, click here, and follow the instructions.
(88741) -
i tried to sinc my photos and i ended up deleting off my phone all the pictures. i only ended up with one folder, and i cant figure out how to put rest of folders from my computer back on my phone.....help
and on a second problem. I need to know for sure that my contacts are backed up on my computerCreate a parent folder on your computer to store the named folders of photos that you want transferred to your iPhone. Under the Photos tab for your iPhone sync preferences with iTunes, select the parent folder. All named folders of photos within will be transferred to your iPhone as separate folders or albums.
Regarding your 2nd question, this should be easy. Your contacts should be available on your computer with or without an iPhone or any cell phone, which can be lost or stolen.
Although contacts are included with your iPhone's backup which is updated by iTunes as the first step during the iTunes sync process, not a good idea to depend on this either since the iPhone backup includes a significant amount of other data. Contacts are designed to be synced with a supported address book app on your computer. With Windoze, this can be with Outlook 2003, 2007, or 2010 along with syncing calendar events and notes, or with the address book app used by Outlook Express with XP and by Windows Mail with Vista and Windows 7 called Windows Contacts for syncing contacts only. -
I have a gen 3 ipod and can't get it into disk mode. In itunes it does not have the option and I cant figure out how to do it on the ipod touch itself. Any ideas?
Recovering your iTunes library from your iPod or iOS device: Apple Support Communities
-
I have an older mac and it wants me to update to itunes 10 but my mac is too old and I cant figure out how to disable the update so I can use the store.
If Software Update is offering the update then it would be compatible with your model. Unfortunately, you haven't provided us with any information on your hardware that would enable us to determine if it really is too old.
If you really wish to disable the update alert then the next time Software Update opens, select the update in the list then select "Ignore update" from SU's Update menu.
Maybe you are looking for
-
Multiple Domains/Website On Single Hosting Plan
I currently host my website with a shared hosting company that uses the latest version of ColdFusion MX. I recently registered a second domain and pointed it to the same IP address. I found some code on another ColdFusion forum that allows you to dir
-
I want to send a photo to Geico Insurance company, Geico. How do I do it?
-
JTable, column names not appearing!
I am using the following code: Vector columnNames = new Vector(); Vector data = new Vector(); try // Connect to the Database Common.Data.DataAccesser da = new Common.Data.DataAccesser(); Connection
-
Dear GURUs While running TCODE FBRA it is taking long time due to lots off record is available in table BKORM, The solution is delete all records from BKORM through F.63, is there any effect if we delete all record from Table BKORM. By which T. code
-
MacBook Screen Flashes and Refreshes every 2 seconds after autoupdate
My daughter installed updates last nite (she thinks itunes, safari, quicktime?) and now her computer will turn on but the display keeps refreshing and will not completely display all her usual icons. I tried resetting the PRAM (Control Command P R) a