I am no good at this

Hello everyone out there on the internets. I am in my third week of a Java class. I am trying to show at least a small amount of progress to my instructor, so if anyone could tell me where my stupid mistakes are in this code it would be greatly appreaciated. I am getting an error in my constructor on line 36 I will put a comment there.
Thanx
import javax.swing.JOptionPane;
import java.text.*;
public class lunchredo
      // Variable Declaration
        private static double appleCost;
       private static double appleQty;
       private static double breadCost;
       private static double breadQty;
       private static double cheeseCost;
       private static double cheeseQty;
       private static double wineCost;
       private static double wineQty;
       private static double budget;
       private static double totalCost;
    public static void main(String[] args)
// right here is where the error is
    // constructor setting the values        
  Lunch()
     appleCost = 1.09;
     appleQty = 4;
     breadCost = 2.55;
     breadQty = 3;
     cheeseCost = 5.99;
     cheeseQty = 2;
     wineCost = 52.06;
     wineQty = 6;
     String yourbudgetString;
            double budget;
          yourbudgetString = JOptionPane.showInputDialog(null, "Enter Your Budget.", "Budget", JOptionPane.INFORMATION_MESSAGE);
          budget = Double.parseDouble(yourbudgetString);
          public static double setTotalCost
   totalCost = (appleCost * appleQty) + (breadCost * breadQty) + (cheeseCost * cheeseQty) + (wineCost * wineQty);
              public static double displayTotal(){
                  DecimalFormat df = new DecimalFormat("#0.00");
                  System.out.println(df.format(LunchCost(0.00)));
                  return totalCost;          
         public static double totalExpense(double expense){
                  expense = budget - totalCost;
                  return expense;
             public static double displayExpense(){
                  DecimalFormat df = new DecimalFormat("#0.00");
                  System.out.println(df.format(totalExpense(0.00)));
                  return expense;
     public static double getBudget()
              return budget;
  public static double setTotalCost
   totalCost = (appleCost * appleQty) + (breadCost * breadQty) + (cheeseCost * cheeseQty) + (wineCost * wineQty);
  public static double getTotalCost
       return totalCost;
  public static double spendBudget(double remainder)
            double remainder = budget - totalCost;
df.format(remainder);
JOptionPane.showMessageDialog(null,"Your budget is $" + df.format(budget) + " and the total cost of the lunch is $" + df.format(totalCost) + "." + " You have $" +
df.format(remainder) + " remaining");
  //If statement that decides whether or not the budget is exceeded
     if (remainder < 0)
     JOptionPane.showMessageDialog(null,"You have exceeded your budget. Please go home and get more money!");
     else
     JOptionPane.showMessageDialog(null,"You have not exceeded your budget.");  
     //Output Section
     private static double lunchOutput()
     System.out.println("Price of Apples per pound: $" + df.format(appleCost));
     System.out.println("Price of Bread per loaf: $" + df.format(breadCost));
     System.out.println("Price of Cheese per pound: $" + df.format(cheeseCost));
     System.out.println("Price of Wine per bottle: $" + df.format(wineCost));
     System.out.println("Total Price of all items: $" + df.format(totalCost));
     System.out.println("Your Budget: $" + df.format(budget));
     System.out.println("You have: $" + df.format(remainder));
     System.exit(0);
}

Remove static from everything except main. Good point. The poster's code has the bad smell I dub:
static cling: you try to access a field/method from a
static context and get the syntax error "non-static
variable/method ... cannot be referenced from a static
context", so to get rid of that error you make the
field/method static but the error just spreads and clings to
your code until everything is declared static!
Your teacher will pull you up on this if you don't.Let's hope. But you may be expecting too much from some
teachers. We've had a few in these forums who were real
peaches.

Similar Messages

  • IPAD 6.0 (MD519C/A) wifi,cellular - how good is this model?

    I would like to buy Apple iPad with Retina display (MD519C/A), 16GB, WiFi, Cellular 4G, White from Staples.ca. I would like to know if anyone has used this model and how good is this. Also, whether it's unlocked or not? I want to send the ipad to Bangladesh and the customer representative at Staples was not sure whether that is unlocked or not. I would like to know if it would work there.
    I have pasted the URL for this ipad. Thank you.
    http://www.staples.ca/en/Apple-iPad-with-Retina-display-MD519C-A-16GB-WiFi-Cellu lar-4G-White/product_105913_2-CA_1_20001

    Without checking myself, just be aware that the iPad OS generally only provides error signals that are relevant. It wouldn't seem relevant to report on a missing SIM with Cellular turned off, and I'd therefore expect that you wouldn't see that message after having done so.
    Don't turn on Airplane Mode, however (that's what's shown by the "little airplace icon") as that also shuts down your wifi.
    And yes, with Cellular off it just says "iPad" there on the status bar, exactly as described in your User's Guide and other locations.

  • Please recommend personal finance software for Mac that allows month to month analysis of spending by categories.  Quicken on a PC was good at this.  Mint seems very limited.

    Please recommend personal finance software for Mac that allows month to month analysis of spending by categories.  Quicken on a PC was good at this.  Mint seems very limited.

    Quicken for Mac 2007 works just fine (and is said to be compatible with Mavericks).  It is often denounced for not being "modern", but when something works, and does everything I want, I need a good reason to switch. 
    A few years ago (2011), I got that reason when I upgraded OSX and Quicken stopped working due to the absence of Rosetta.  I switched to iBank.  I used it for more than a year.  It was cumbersome, they have no sense of a helpful user interface, but it "works".  I found ONE feature that I liked:  you can attach an image (or any file) to a register entry, so I can save receipts right with the register.
    But when Intuit came out with the revised Quicken 2007 for Mountain Lion, I gladly went back.  I found that being able to update stock prices right in the portfolio view (for those not automatically found online) was handy - in iBank you have to generate a report to see the holdings, and then you have to switch to a view of "Securities" then scroll down through that list to find your stock, then "edit" then change the price, then "Save" then go back to reports and re-generate the portfolio view.  Also, if you enter a stock purchase in a Quicken register, the price you paid gets added to the price history for the stock (as of the date of the transaction).  No such help in iBank.  Most of the helpful UI features (like increasing the date with the + key) are glaringly missing in iBank.  I find I am getting no more than about 3-4 keystrokes before having to move the mouse and click.
    If you are considering sharing the app on an iPad, Quicken won't work, but I found that iBank for iPad doesn't work either.  The interface is completely different from the Mac version, you can't do much with it, and if you have a stock whose price is $11.25 / share and sell 200 shares, you might find that $22.50 gets added to your cash in the account.  (I actually made a few million dollars when it decided that 200 shares at $11.25  yielded $2,250,000.)  Luckly, I received a refund for that app.
    Depending on how the Mavericks switch goes, I hope to be able to stick with Quicken, but I am keeping my records up-to-date in both now, because I can live with iBank.  I will just have to keep an eye on its arithmetic.

  • When ever I launch my safari, it will stay on for about a minute and then quits on me. It has a "safari quit unexpectedly" dialog box with a bunch of codes that I can send a report to apple. im not very good with this kind of thing, plz help!

    Im not very good at troubleshooting, but I have played around with the system preferences. My airport connection is fine as well as the ethernet. Firewall says its not connected, (im not sure if that matters or not?)
    I have subtracted my network from the list, restarted, and then put it back and and restarted...nothing seems to be working. Iam in the middle of a correspondace course and i really need my internet back...any suggestions would be greatly appreciated!
    Thank you

    Could be many things, we should start with this...
    "Try Disk Utility
    1. Insert the Mac OS X Install disc, then restart the computer while holding the C key.
    2. When your computer finishes starting up from the disc, choose Disk Utility from the Installer menu at the top of the screen. (In Mac OS X 10.4 or later, you must select your language first.)
    Important: Do not click Continue in the first screen of the Installer. If you do, you must restart from the disc again to access Disk Utility.
    3. Click the First Aid tab.
    4. Select your Mac OS X volume.
    5. Click Repair. Disk Utility checks and repairs the disk."
    http://docs.info.apple.com/article.html?artnum=106214
    Then try a Safe Boot, (holding Shift key down at bootup), run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions, reboot when it completes.
    (Safe boot may stay on the gray radian for a long time, let it go, it's trying to repair the Hard Drive.)
    Then GULP, check for this...
    Flashback - Detect and remove the uprising Mac OS X Trojan...
    http://www.mac-and-i.net/2012/04/flashback-detect-and-remove-uprising.html
    In order to avoid detection, the installer will first look for the presence of some antivirus tools and other utilities that might be present on a power user's system, which according to F-Secure include the following:
    /Library/Little Snitch
    /Developer/Applications/Xcode.app/Contents/MacOS/Xcode
    /Applications/VirusBarrier X6.app
    /Applications/iAntiVirus/iAntiVirus.app
    /Applications/avast!.app
    /Applications/ClamXav.app
    /Applications/HTTPScoop.app
    /Applications/Packet Peeper.app
    If these tools are found, then the malware deletes itself in an attempt to prevent detection by those who have the means and capability to do so. Many malware programs use this behavior, as was seen in others such as the Tsunami malware bot.
    http://reviews.cnet.com/8301-13727_7-57410096-263/how-to-remove-the-flashback-ma lware-from-os-x/
    http://x704.net/bbs/viewtopic.php?f=8&t=5844&p=70660#p70660
    The most current flashback removal instructions are F-Secure's Trojan-Downloader:OSX/Flashback.K.

  • HELP! i'm not good with this

    Alright, so for one of my college classes we are working with garage band and we are forced to make a song completely with the loops. We are not allowed to use anything else (not that I would know how to anyway) but that's beside the point. I was just wondering if anyone could give me any tips on using the loops? I have a sound that i'm liking so far but I really want to change the key i'm in...(maybe thats what its called, i don't even know) and i was wondering if you can change the loops around so you can hear what you want and have a little variety in the the sound. I know i'm not doing a good job of explaning what i want...but i'm really very unexperienced with garage band.
    Thank you very much!!!!

    It sounds like you what to change the harmony of a loop, like changing chords on a guitar. If so, you can do that with the Track Editor (the icon looks like a sissors cutting a waveform). To see how it works try this:
    - Drag a loop into a track (a struming guitar works well).
    - Option-drag out a couple of copies of the loop.
    - Select the 2nd copy and open the Track Editor.
    - Move the Region Pitch slider to +4.
    - Select the 3rd copy and move the current time indicator to the midpoint. Edit>Split to cut it into 2 pieces.
    - In the track editor set the Region Pitch of the 1st half to +5 and the 2nd half to -4. (+5 and -4 are the same chord, just a way to get variety).
    Listen to what you've done... it's the standard 3 chord pattern (I/IV/V) at the heart of so many rock songs.
    Hope this helps,
    Charles
    17" iMac Intel core duo   Mac OS X (10.4.7)   1 gb ram/Garageband 3/Firewire Solo

  • What good is this support vehicle if questions go unanswered....

    I am very disappointed. I have been having problems installing SP3. At this point I can neither install or uninstall my original version or SP3. As suggested I posted my question 3 days ago on how to resolve this on this site with the understanding that it was monitored and that an SAP representative would reply.
    The days have passed and still no reply and no program to use while the work piles up. "Disappointing" is not strong enough to describe my reaction. To sell a product, not provide basic support on installation, suggest a forum for support and leave it unmonitored and problems is absolutely cynical.

    Albert, I think you've misunderstood the purpose of these forums. While you might have a question of such importance that a SAP person will pick it up (such as Marilyn), most of us members aren't SAP employees. We answer questions that we feel we can answer. And we post questions, in the hope that one of the other members will voluntarily help out.
    For timely responses to issue, that SAP are responsible for, then OSS (or whatever it is called now)  is the route - But SAP hope you'll get the answer through these forums, because it's a lot cheaper for them
    I've had problems to do with stuff I'm developing and had fantastic help from other members... but by no means can I ever demand such assistance.
    I'm not in any way an SME for your problem. However, in the ABAP area, there are many questions we get that are fantastically important to the questioner, but have been answered many times, or are trivial. I'm not suggesting that yours are in this categorgy, but such questions are also unlikely to get good answers. The quality of questions is often reflected in the quality of the answers, as my sig used to run in SAPFans.

  • How good is this software?

    Years ago I remember playing with Sound Edit Pro on my LC III. Since then I bought SoundMaker (which still runs in classic).
    This software may be overkill is all I really need a sound editor for is my website. I do not do professional video. My needs are far more than what the built in garbage provides with Mac/Windows but not enough for professional software.
    So what do you guys use this software for? Is it film? Radio?
    John

    John
    This is great software for using with a website. I use STPro for both audio and film scoring. I am a webmaster. I am currently using STPro for my fourth self-produced music CD. My last CD was done in a really good studio with Pro Tools. I was ready to buy Pro Tools, but I had Sound Track and started trying it out. With the upgrade to STPro, there is nothing in Pro Tools I can't do in STPro except record multiple tracks in. (Since I do mostly vocal, guitar and overdubs this is unimportant for me.)
    I don't have crashes, mixes that sound different, or other problems. It took me a while to learn the basics of reverb and compression/limiting, but the info is there to read in the manuals. The presets save me lots of time. The ability to use my keyboard (M-Audio49e) in Garageband to access the software instruments and then bring them back into STPro has been wonderful. I have been recording on the Mac since 1999.
    The key has been this forum. I have learned so much thanks to all the Pro's who volunteer their time. I hope this helps you figure out if STPro is what you want to use.
    David

  • How good is this Laptop?

    Im looking for a new laptop because I will be starting college in a few months. Im looking for a good school computer but also a good gaming one for my spare time as well. This is the laptop I was looking at:
    HP - 15.6" Pavilion Laptop - 6GB Memory - 750GB Hard Drive
    SPECS:
    http://www.bestbuy.com/site/HP+-+15.6%22+Pavilion+Laptop+-+6GB+Memory+-+750GB+Hard+Drive+-+Steel+Gra... 
    Here's the website for the specs because of the quantity of material in it, it would be to much for me to write down.
    But I can say that it has a 2.5GHz processor, 16GB RAM, 750GB Hard Drive Size, AMD Radeon HD 6620G graphics, Up to 3061MB video memory, Windows 7 Home Premium 64-bit, ETC!!!

    This computer, although a good one, has integrated graphics that uses shared system RAM for video memory.  As such, it will not be a great gaming machine. It will perform superbly for your school work and realted functions, but gaming will not be as good.  It does have a very good processor and a good graphics solution, but it is integrated graphics and not discrete.
    A very good all round laptop, just not a great gaming machine.  Casual gaming will be pretty good, but running the latest games at high rame rates probably isn't going to happen. 
    If you can live with that, it is a good deal.
    If you find my post useful or informative, please click the icon below with the plus sign and star to give kudos. Thank you!

  • Is materilized view good in this case?

    i have two database across different network. I need to replicate couple of tables from main machine to another. This "refresh" has to be every 5 seconds or so.. Do you think it's good idea to have materized view this 5 seconds refresh or any other better option. Tables are not that big .. only 50 to 60 thousand rows in each with 50 columns ...
    thanks in advance

    This "refresh" has to be every 5 seconds or so.I don't know if a MV is well for a refresh too often like this. Take care to the time of refresh which should less than 5 second, if not, the refresh will occur permanently.
    Are you sure that you want 5 second refresh ?
    Why not, in that case, query directly sources tables through the dblink instead of MV ? How often should queried your MVs ?
    I would think a little more, before apply MV in your case.
    Nicolas.

  • Please CL release a good driver this month so we can enjoy the upcoming DX10 ga

    nVidia had been doing a pretty good job in improving their driver. They now have a working DX0 SLI 8800 driver even though its performance is still behind XP performance. They are at least releasing drivers about once per month.
    What about CL? The current XFI driver is not cutting it. You cant possibly believe this is the final Vista driver we are to have to use right? I have been reading the forum and I find no mention of a new driver to be released. There are no beta drivers either. I bought the game DiRT and it is unplayable in Vista due to CLs XFI driver. Its fine in XP. I just want to know where we stand at getting support for our cards and ultimately whether we can use Vista or not?

    If you can get past the fact the Prelude will be X-fi dri'ven, its a **bleep** fine looking piece of hardware. I think creative might be on the right path liscensing out the x-fi processor and letting sombody else develop the card. Until now CL has manufactured its cards in their entirety and that has provewn to be a very expensi've way to do business, complete propriety is not the way to go financially, I see the release of the x-fi chip to third parties as corporate re-structuring to some degree. Personally, it does not really mater to me who owns what license as long as the hardware works, and works well. There are some other cards being developed and they too will hit the streets soon (cannot mention them here) But they are out there. I spoke to a tech representati've at meridian a couple weeks ago and basically explained that I would not buy their card either if the driver support was going to be anything like what we have suffered from CL over the present X-fi, and he explained the drivers would be skinned way down as all they need to be is functional, and the software was all their baby. We'll see what happens. And if this card does not pan out, another long time player in the computer field is releasing an awesome looking piece of equipment this fall. So, all may not yet be lost ....

  • Good work this site in iphone or ipad? balsavimas.eu

    http://balsavimas.eu good work?

    Allan, thanks for trying but as I pointed out in my original post, all other activity requiring an apple id works fine. The problem is only located to the updates section of the App Store on the device only. It is only here that an incorrect username is being presented by the app which is preventing updates on the iPhone and iPad.
    I am posting here because others may have experienced a similar problem and found a solution that could help me and someone else who might also have this issue. Thanks to anyone who can help.

  • Apple how did you make the microphone so good on this phone.

    Its so good in fact that i l recorded a few songs with a full band drums and all and it sounds pretty good so cheers apple. http://snd.sc/qZSjkl a song recorded on my iPhone called Carousel Ride.

    Okay, narrow is narrow.  Just need to make sure we're clear on the point that we're discussing the top and bottom margins. 
    I just found another post that led me to "Defining Layout Margins" in the Pages help files.  Between that post and the information in this help message (specifically item #4), I was able to deduce that Pages does enable me to do exactly what I need.
    1 - set the page margins on page one;
    2 - create a layout break at the bottom of page 1, which will effect the next page;
    3 - with the cursor on page 2, open the inspector;
    4 - go to the layout inspector;
    5 - change the "before" margin.
    In the layout inspector dialog box, "before" = "top" and "after" = "bottom", not as in paragraph or line formatting.  I don't know why it couldn't just say top and bottom.  That would eliminate a lot of confusion.
    This has enabled me to have one top margin on the first page and a different top margin on all other pages. However, as nothing is perfect, this process must be repeated on each page.  A little more work but definitely worth the effort, if you need this type of formatting.  Better than not at all in other words.
    Thanks for your time and help.
    Ross

  • Hi hello...I have a problem deleting unwanted albums in my phone/photos, any one who can help me do it step by step please.Have patience with me I am not so good with this.

    Hi Hello,
         Before I start my question, hope nobody laugh at me, I am not a computer geek, I just a user of a phone.
    I have read so many how to do and how to delete albums in the web/google but not anyone of them make sense to me,I hope someone can help me do this step by step.
    I am using an iphone 4/operating system 7.0.4
    I would like to delete the unwanted albums in my phone under the photo icon, where do i start?
    like...   1/ connect the phone to the computer
                2/ click the itune icon
                3/ then whats next?
    Please help I could not download anyother app, the system( phone )  always tells me that memory is almost full, I am already frustrated, please help.
    If I reset the phone will it erase all the phone numbers and remove all my notes?
    Thank you.
    <Email Edited by Host>

    Hi mylenebar!
    Here is an article that will help you remove the desired photos from your phone:
    iTunes: Syncing photos
    http://support.apple.com/kb/ht4236
    To delete synced photos and videos from your device
    In iTunes, click the Device button in the upper right corner. (If viewing the iTunes Store, click the Library button in the upper-right corner first.)
    Click the Photos tab in the resulting window.
    Choose "Selected albums" and deselect the albums or collections you want to delete.
    Note: To delete all synced photos, deselect "Sync Photos from" and, when asked, click "Remove photos."
    Click Apply.
    Thanks for coming to the Apple Support Communities!
    Cheers,
    Braden

  • [Solved] Could someone that knows awk good fix this script for me?

    I found this script on the linuxquestions site that tests and displays network bandwidth.  There's an error in the script though and my awk experience isn't enough to debug it and is giving me the error:
    awk: cmd. line:10: printf ("%4.0f", Ratio)}
    awk: cmd. line:10: ^ syntax error
    awk: cmd. line:10: printf ("%4.0f", Ratio)}
    awk: cmd. line:10: ^ syntax error
    ^C/home/todd/.bin/bandwidth-test: line 21: [: : integer expression expected
    BW Surchargé - Moyenne de de Kb/sec pendant 20 secondes
    This is the script:
    #!/bin/bash
    # bandwidth-test - test bandwidth from the command line
    Fic_Tmp="/tmp/Fic_Tmp_VerifRatio.tmp"
    NbrSec=20
    /usr/bin/bwm-ng -I eth0 -o csv -T avg -C " " -c ${NbrSec} | awk '
    BEGIN{
    BytesS=0
    NbrLecture=0}
    /eth0/&&NR>2{
    BytesS+=$5/1024
    NbrLecture+=1}
    END{
    Ratio=BytesS/NbrLecture
    printf ("%4.0f", Ratio)}' > ${Fic_Tmp}
    Ratio=$(cat ${Fic_Tmp})
    rm ${Fic_Tmp}
    if [ "${Ratio}" -lt 110 ];then
    echo "BW OK - Moyenne de ${Ratio} de Kb/sec pendant ${NbrSec} secondes"
    exit 0
    else
    echo "BW Surchargé - Moyenne de ${Ratio} de Kb/sec pendant ${NbrSec} secondes"
    exit 2
    fi
    exit $?
    Anyone available to fix this for me?
    Last edited by Gen2ly (2009-11-17 17:52:14)

    Ah, thought I counted all those.  Whoops .  Yep that did the trick.  Thanks benob.
    Edit: Just FYI to any that read this.  This script only checks if you are in the cap range, so it's not really a bandwidth tester for the command line.  The nearest I've found is 'iperf' which I'm unable to get to use yet.
    Edit2 : netperf seems better suited for this, only been able to learn how to do download speed test so far:
    netperf -c hostname -f K
    Last edited by Gen2ly (2009-11-17 19:08:38)

  • How good is this new MCE hard drive?

    Has anyone heard of this new hard drive from MCE? I guess it allows you to install another hard drive into your MacBook Pro. This is the link... http://www.mcetech.com/optibay/. What are the negative issues this could bring up? Heat issues im guessing...
    MacBook Pro   Mac OS X (10.4.8)  

    Yeah, I would love to hear from anyone who has done this...! I think the idea is great, but have no idea the impact on heat and battery life! I wonder, if the heat and battery issues are negligible, how great this setup could be with the forthcoming Time Machine (Leopard!)...!

Maybe you are looking for

  • How do I install my color laserjet 2605 dn on my windows vista laptop.

    I have been using an HP Color Laserjet 2605 dn on my aging Windows XP computer.  Now that the system is becoming unreliable, I purchased a new HP desktop with Windows 7.  My printer is not compatible with Win7, so my other option is to use it on my H

  • SQL recursion problem in custom groups table

    hi all, Consider the following seemingly simple table structure ( with sample rows ) : PERMISSION_ID P_ID DESCRIPTION DESIGNATION ============= ==== =========== ======= 1776 Null Z-ENGINEERING 88888 1860 Null Z-LABORATORY 88888 1909 Null Z-RESEARCH 8

  • Time Machine deleted my old backups and crapped out midstream

    I had just gotten my failing hard drive replaced, and restored from Time Machine backup. So far so good. So a week later, I wanted to upgrade to Mountain Lion, but figured I should be responsible and run Time Machine backup again before doing the upg

  • Problems with importing Iphoto

    Anyone having this problem?? I just got this computer last week and I scanned one picture. I tried to import it and the program keeps going and going and it won't import. But now everytime I go into I photo it asks do I want to import of course NO an

  • Subject in Alert Message

    Hi All, I have configured Alert and receiving alert successfully as an Email. In my sceanario, i m triggering alert in BPM and need to pass payload as an Email body so used container. and ticked Dynamic Text option in ALRTCATDEF. So now I m getting e