Why cant i send this to the cost class on button click?

when the calculate button is clicked i want the program to check and see if a certain checkbox is selected and if set a variable in another class.
in the code below. why does it not recognize that i am trying to send the variable from the checkbox to the set method in the cost class?
public class ButtonHandler implements ActionListener{
          public void actionPerformed(ActionEvent ae){
               if(ae.getSource()==jbnCalculate)
                    String f = jtfFirst.getText();
                    String l = jtfLast.getText();
                    String id = jtfID.getText();
                    if(cbCream.isSelected()){
                         app1.setCream(ch);
package final_Kelm;
public class GMCCost extends GMCEmployee {
     double white;
     double wheat ;
     double creamCheese;
     double butter;
     double peachJelly;
     double blueberryJam;
     //double regularCoffee = 1.25;
     //double mocha = 2.75;
     //double latte = 3.05;
     double coffee;
     double total, subTotal;
     double TAX_RATE = 0.0825;
     public GMCCost()
          total = 0.0;
          subTotal = 0.0;
     public void setCoffee(double c)
          if(c==1)
               coffee = 1.25;
          else if(c==2)
               coffee = 2.75;
          else if(c==3)
               coffee = 3.05;
          else
               coffee = 0.0;
     public double getCoffee()
          return coffee;
     public void setCream(double ch)
          ch = 0.5;
          ch = creamCheese;
     public double getCream()
          return creamCheese;
     }i am having the same trouble with the coffee. i cannot add it to the output by "Coffee Price: " + app1.getCoffee() + . . . . .

why is this considered wrong or bad . . .
public class ButtonHandler implements ActionListener{
          public void actionPerformed(ActionEvent ae){
               if(ae.getSource()==jbnCalculate)
                    double butter, peach, blueberry, white, wheat;
                    double creamCheese, subTotal, total;
                    String f = jtfFirst.getText();
                    String l = jtfLast.getText();
                    String id = jtfID.getText();
                    double TAX_RATE = 0.0825;
                    if(cbCream.isSelected()){
                         creamCheese = 0.5;
                    else{
                         creamCheese = 0.0;
                    if(cbButter.isSelected()){
                         butter = 0.25;
                    else {
                         butter = 0.0;
                    if(cbPeach.isSelected()) {
                         peach = 0.75;
                    else {
                         peach = 0.0;
                    if(cbBlueberry.isSelected()) {
                         blueberry = 0.75;
                    else {
                         blueberry = 0.0;
                    if(jrbWhite.isSelected()) {
                         white = 1.25;
                    else{
                         white = 0.0;
                    if(jrbWheat.isSelected()) {
                         wheat = 1.50;
                    else {
                         wheat = 0.0;
                    double coffee = jcbCoffee.getSelectedIndex();
                    if(coffee==0) {
                         coffee = 0.0;
                    else if(coffee==1) {
                         coffee = 1.25;
                    else if(coffee==2) {
                         coffee = 2.75;
                    else {
                         coffee = 3.05;
                    subTotal = white + wheat + creamCheese + butter + peach + blueberry + coffee;
                    total = subTotal + (subTotal * TAX_RATE);
                    jtaOutput.setText("");
                    output = output+ "Employee Information: " +"\nStaff ID: " + id + "\nStaff First Name: " + f + "\nStaff Last Name: " + l +
                    "\nInvoice: " + "\nSubtotal: " + subTotal + "\nTotal: " + total;
               jtaOutput.append(output);
               }as compared to the code i first posted . . . . . this code works . . . the gui works . . . and im assuming this class of code can run all by itself and does have or need anything to do with the other 3 classes are in this program (see previous thread).
this program works but all the code is in the button handler class . . . i do not need to send anything anywhere, i do not need to use set get methods . . . so why would this code be frowned upon?

Similar Messages

  • Why cant I send mail from the mailapp on My ipad?

    I can't send maila from the mailapp on My ipad air. What can the problem be? Pelare help me :)

    The parameters for the outgoing email server are probably not set correctly in your Mail account in Settings > Mail, Contacts and Calendars.
    Check these carefully to make sure that User name, password, server name, port, and password are correct.
    If you need more help then who is your email provider?

  • Why cant I send emails from the regular email app anymore?

    Hi,
    Suddenly one day I noticed that the icon that I use to create a new email had disappeared. What is the reason for this change in the email app (gmail and hotmail) and how can I get it back?
    Thanks a lot in advance

    Remove the mail accounts from the device and add them back, it wont hurt your mail and you wont lose anything because Gmail saves all your mail anyway.
    So go to Settings>Mail,Contacts<Calendars and then click on each account, go to the bottom and choose - Delete Account.
    Once you have removed them, go to Add Account> and click on gmail and hotmail, then sign in to each account.
    This should resolve your issue.

  • I can only scroll using the arrow keys. In IE/C I can use the touch pad to slide my fingers to scroll. Why cant i do this in FF?!?!

    On my laptop (and most for that matter) you can use the touch pad to slide your fingers to scroll thru a web page. I cannot do this in firefox. It is very annoying and I dont know why cant do this?
    I have reinstalled FF and it still wont scroll! Every other browser i can scroll thru a web page using the touch pad method.
    Why cant i do this on FF?

    Hello and Welcome to Apple Discussions!
    Full keyboard access is useful for people who have difficulty using a mouse. Safari supports standard full keyboard access shortcuts for buttons and menus. If you choose, you can also use the keyboard to highlight links in webpages.
    To turn on full keyboard access:
    Choose Apple menu > System Preferences and click Keyboard & Mouse.
    Click Keyboard Shortcuts.
    Select the checkbox to turn on full keyboard access.
    To highlight links in webpages using the Tab key:
    Choose Safari > Preferences and click Advanced.
    Select the option to highlight each item on the web page using the Tab key.
    With full keyboard access turned on, Safari uses the standard shortcut keys to access menus and windows, plus the additional shortcuts shown in the table.
    Hope this helps!!
    Carolyn

  • Why cant I send mail to myself from the ipad. It remains in the out box

    Why cant I send mail to myself from the ipad. It remains in the out box.
    I am using the wifi only.

    Why cant I send mail to myself from the ipad. It remains in the out box.
    I am using the wifi only.

  • Why cant i send videos?

    my boyfriend has the original droid and can send up to 1min long videos thru text. i have the droid 2 and cant send videos in any format thru text. and i can only send certain ones to emails.  so why cant i send them by text? and they are short videos. less than 30 secs.

    Within the camera, before you record your video, go into settings and make sure you have the video length and quality set to the "for MMS" settings. Are you taking these steps below to send a video through text?
    From the home screen, touch the applications tab (located at the bottom of the display). 
    Touch Gallery. 
    Touch a gallery (e.g. All videos).
    Touch and hold a video.
    Touch Share. 
    Text messaging
    If presented, touch Yes.
    To resize, touch Menu.
    Touch Resize.
    Touch one of the following options then touch OK:
    176x144
    320x240
    Touch Menu.
    Touch Done.
    Touch No.
    From the To field, enter a 10-digit mobile number .
     As the number is entered, a matching contact may appear and can be selected at any time.
     Alternately, touch the contacts icon (located on the right-side of the To field), touch a contact, touch the appropriate mobile number then touch OK.
     Repeat this step as necessary to add additional recipients.
    To add a subject, touch Menu.
    Touch Add subject. 
    Enter a subject. 
    From the Enter message here field, enter a message.
    Touch Send. 
    Here is a link for additional information. Click here http://support.vzw.com/clc/devices/knowledge_base.html?id=34758#messaging

  • Why cant i send my messages

    Why cant i send my messages

    Messages only works with other iOS devices and with Mac computers running Mountain Lion or Mavericks. In addition to that, the other person that you want to message with must already be registered and set up to use messages on their device. You cannot add them on your own from your device, they have to set it up first on their own.
    If those conditions have been met, try this. Go to Settings>Messages>Show Subject field>Off.

  • Why cant i do this?

    Hi,
    I tried doing this but it's not allowed.
    String     HOST = "jdbc:odbc:LogAccess",
                 DRIVER = "sun.jdbc.odbc.JdbcOdbcDriver";
         try {
              // connect to db
              Class.forName(DRIVER).newInstance();
              Connection con = DriverManager.getConnection(HOST,"","");
              PreparedStatement ps = null;
              if(TABLE_NAME.endsWith("2002")){
              String query = "INSERT INTO WebLog2002 VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)";
              }else{
              String query = "INSERT INTO WebLog2001 VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)";
              ps = con.prepareStatement(query);
              int count=0;
              while(count<=totalRows) {The error is
    C:\newclasses\logger3.java:174: cannot resolve symbol
    symbol : variable query
    location: class logger3
              ps = con.prepareStatement(query);
    ^
    1 error
    Tool completed with exit code 1
    Why is that so?
    Please advise...thanks....

A: Why cant i do this?

Declare query before you enter the if statement.
String query = null;
if (condition) {
  query = ...
} else {
  query = ...
}or use the ? : syntax
String query = TABLE_NAME.endsWith("2002") ?
  "INSERT INTO WebLog2002 VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)" :
  "INSERT INTO WebLog2001 VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)"If TABLE_NAME is WebLog2002 or WebLog2001, you can do it as:
String query = "INSERT INTO "+TABLE_NAME+" VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)";

Declare query before you enter the if statement.
String query = null;
if (condition) {
  query = ...
} else {
  query = ...
}or use the ? : syntax
String query = TABLE_NAME.endsWith("2002") ?
  "INSERT INTO WebLog2002 VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)" :
  "INSERT INTO WebLog2001 VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)"If TABLE_NAME is WebLog2002 or WebLog2001, you can do it as:
String query = "INSERT INTO "+TABLE_NAME+" VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)";

  • HT1349 why cant photos i take on the iphone play on a digital photo frame ?.

    Why cant photos i take on the iphone play on a digital photo frame they are all on the flash drive cos they play on the tv

    Hi Smallteacher07,
    Welcome to the Support Communities!
    The article below may be able to help you with this.
    iCloud: My Photo Stream troubleshooting
    http://support.apple.com/kb/TS3989
    I hope this information helps ....
    Happy Holidays!
    - Judy

  • TS4268 why cant i send imessage with my iphone number

    why cant i send imessage with my iphone number,my number is there but I can't click it I can only use my emails

    Without more informnation
    iOS: Troubleshooting Messages
    The Complete Guide to FaceTime + iMessage: Setup, Use, and Troubleshooting | iLounge Article

  • TS2771 why cant i send messages to my iphone or anyone elses phone from my ipod

    why cant i send messages from my ipod touch to my iphone or any other phone

    Without more informnation
    iOS: Troubleshooting Messages
    The Complete Guide to FaceTime + iMessage: Setup, Use, and Troubleshooting | iLounge Article

  • Why cant I add contacts on the iphone4? the mail contacts calendars button unders settings, the contacts button, the add a contacts button under message and the phone button will not work to add a contact.

    Why cant I add contacts on the iphone4? the mail contacts calendars button unders settings, the contacts button, the add a contacts button under message and the phone button will not work to add a contact.

    Have you attempted a restore?

  • Why cant i download all of the itunes songs off my wifes purchased itunes account when using the family sharing? some songs i can and some it wont let me

    why cant i download all of the itunes songs off my wifes purchased itunes account when using the family sharing? some songs i can and some it wont let me

    Place the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
    iOS: Wrong passcode results in red disabled screen                          
    If recovery mode does not work try DFU mode.                         
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings         
    For how to restore:
    iTunes: Restoring iOS software
    To restore from backup see:
    iOS: How to back up
    If you restore from iCloud backup the apps will be automatically downloaded. If you restore from iTunes backup the apps and music have to be in the iTunes library since synced media like apps and music are not included in the backup of the iOS device that iTunes makes.
    You can redownload iTunes purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • Why cant i download music in the Uk the same time as the USA why do we have to wait weeks and weeks to download music when other countries can download it straight away?

    #itunes store. Why cant i download music in the UK the same time as in the USA? Why do we have to wait weeks and weeks to downloand music when other fans can dowload music in other coutries when it is released in the US?

    Itunes can only provide what the owners of the distribution rights to the music provide.
    If the owner of the rights do not provide it, then itunes cannot sell it.
    You would have to ask the owners of the distribution rights in each country why they do not provide them at the same time.

  • TS1718 Why do I get this message:  The song "title" could not be used because the oringinal file could not be found.  Would you like to locate it?

    Why do I get this message:  The song "title" could not be used because the oringinal file could not be found.  Would you like to locate it?

    John Black3 wrote:
    Many of my songs in my iTunes Library no longer play.  I get this error message: "The song xxx could not be used because the original file could not be found. Would you like to locate it?
    this usually happens when a user moves or deletes files in the finder - a sure way to upset iTunes.
    did you move or delete files in the finder ?
    I cannot locate the song.
    if you let iTunes manage your library, all your content will be in <MacintoshHD>/users/<yourname>/music/iTunes/iTunes music (or media)/music. did you look there ? tried a spotlight search ?
    if the files are really gone, and have been purchased from the iTunes store, see Downloading past purchases from the App Store, iBookstore, and iTunes Store.

  • Maybe you are looking for