I am trying to only display at most two decimal digits.

I am writtng a java app that computes an energy bill, but the computations are only supposed to display two decimals digits at the most.
here is my code, I am trying to find a way to only display the two digits after the decimal in the answer (print statement). I was thinking that I could use a string method or something.
import java.util.Scanner;
public class EnergyCost
public static void main(String[] args)
final double UsageRate = 0.0942;
final double PowerRate = 0.0075;
final double FuelFactor = 0.0001403;
final double TaxRate = 0.082;
int KiloHour;
double EnergyCharge, PowerCost, FuelAdjust, TaxCharge, Total;
Scanner scan = new Scanner(System.in);
System.out.println("Hello! My name is David and I will be helping you today!"); /*Done for aesthetics*/
System.out.println("Please enter the umber of kilowatt-hours used last month: ");
KiloHour = scan.nextInt();
EnergyCharge = KiloHour * UsageRate; /*Calculates the energy charge*/
PowerCost = KiloHour * PowerRate; /*Calculates the power supply cost*/
FuelAdjust = KiloHour * FuelFactor; /*Calcuates the fuel factor adjustement*/
TaxCharge = ((EnergyCharge + PowerCost) -(FuelAdjust)) * ( TaxRate); /*Calculates the Dollar amount of tax*/
Total= ((EnergyCharge + PowerCost) -(FuelAdjust)) + (TaxCharge); /*Calculates the total eneergy cost*/
System.out.println("The Energy Charge is " + EnergyCharge);
System.out.println("The Total Energy Charges is " + Total);
}

> System.out.println("Hello! My name is David and
I will be helping you today!"); /*Done for
aesthetics*/
EnergyCharge = KiloHour * UsageRate; /*Calculates the
energy charge*/
PowerCost = KiloHour * PowerRate; /*Calculates the
power supply cost*/
FuelAdjust = KiloHour * FuelFactor; /*Calcuates the
fuel factor adjustement*/
Do you think these comments add anything to your
code? Also; by convention, variable names should
start with lower-case letters.
I was told that comments are a good thing, and that I should get the habbit to comment as much as possible. It is also a major part of our grade. I was not aware the variable convention. You will have to excuse me but I am just starting. Thank you for letting me know that though.

Similar Messages

  • Only Display if StartsWith is not True

    I'm trying to only display fields that do not start with a zero. 
    I played around with the formula below, but it of course returns a bunch of blank rows because of my "".  Any help or suggestions would be GREATLY appreciated.
    if {field} startswith "0" then "" else {field}

    I used section expert to supress rows where
    {Field}=""
    Probably not the best way to do it, but it worked!

  • The calendar sync is recently not working correctly, not display "All events" but it only displays the last six months for my individual entries. My repeating entires do go back further, though. How do I fix?

    I have an iPad 5.1.1. The calendar sync has started to not work correctly. I have it checked "All events," but it only displays the last two months for my individual entries. My repeating entires do go back further, though. How do I fix?

    HI Jason269. Thanks for your reply, however I wrote that I already have "All events" checked. If All Events is checked and it doesn't diaplay all events, how do I fix? It seems this is a common issue, as I have read many others on here state the same problem.
    I believe my problem occurred when I synced my iMac calendar to my iPad calendar using yahoo. Yesterday, I unsynced them on my iMac controls. When I checked my iPad calendar, all of my old entries reappeared - but only for five seconds and disappeared again. So, the data is saved and still there but cannot be displayed, even when I have All events checked. In fact, it only shows my individual entries for the last two months, but does show all my recurring entries. If I switched to last six months, I will see everything for the last six months. If I switch back to all events, it is only for the last two months.
    As I mentioned, others on here have expressed exactly the same issue, including the two month example and having used yahoo.
    For legal purposes, I need to be able to use the information from my indidual calendar entries in an upcoming court case. So I really need to fix this ASAP!

  • Cover flow displays the same two pieces of artwork for all videos.

    I've been adding a collection of tv series I have on DVD to iTunes 9.1.1, it all worked fine initially, I opened each video up of a series of tv programs and used the "Set Poster Frame" option to capture a frame of the program to use as the artwork for that program.
    I normally have the programs sorted by what tv program they belong to, so Cover flow only displays the first episode of a series' artwork. I'm not sure why though but something I did yesterday appears to have caused cover flow to blow a fuse.
    If I chose to sort by name before, cover flow would display all the artwork for each episode, and it showed all the different artworks correctly. Now though after some fiddling I did which I cannot seem to recount my steps back to, it only displays the same two pieces of artwork from two particular episodes for all the videos when it is sorted via name:
    http://img257.imageshack.us/img257/3052/tvprogcoverflow.png
    I've tried removing all the artwork, but there doesn't seem to be an option to delete the poster frame and the poster frame artwork doesn't show up under the artwork tab for the individual videos so I can't delete anything from there. If I select all the videos and then right click and get info, then select the artwork check box and click OK it seemingly deletes all the artwork... Then replaces it again with the exact same artwork!
    Although cover flow shows each video has having the same artwork if I Get Info each video it clearly shows it having the correct artwork so why cover flow is messing around like this I don't know.
    I've tried deleting the album artwork cache in the itunes folder, didn't work. I even tried deleting my entire itunes folder which I have separate from my library and the hidden prefs file in my actual library, but that didn't work either.
    Interestingly enough, if I re-add all the videos they automatically get listed as films and go under the film tab. When looking at them under their cover flow correctly shows every episode with the right artwork:
    http://img200.imageshack.us/img200/8234/filmcoverflow.png
    As soon as I change the Get Info options tab from Film to TV program either for one video or all of them, then cover flow screws up again.
    Any idea how to fix this annoyance?

    The weird thing is, it worked before. I encoded all the videos previously and had them all listed and didn't encounter this problem, but I noticed I'd forgotten to decomb/detelecine the videos so I deleted everything and re-encoded it all. AFter filling the tags out and setting poster frames again I was thinking of making life easier by just pasting the same artwork for every episode, so I did, but didn't like the results so I deleted it again (I selected every video, used Get Info and pasted the artwork that way).
    I think it was after this that the problem started to occur. In any case I've been through every episode and made sure the name, series, episode and episode id fields are all filled in with incremental values and they are. I even made sure the Sort Name field was filled in on every video. But this didn't work either.
    So, thinking another restart was needed I deleted every video again. Re-encoded them all, again. Set the tags for every video and poster frame again. Finished it all off nicely, checked cover flow and was highly annoyed to find it was STILL showing the same two pieces of art work for every video as shown in that image I posted.
    Ultimately, I wouldn't care so much that cover flow is screwing up like this as I always intended to sort by program anyway so it would only ever display one piece of artwork for an entire series of videos, however where-as when it was working it picked the artwork for the first episode of a series to display, its instead picking one of the latter episodes. I can't seem to find any way of choosing what artwork I want displayed.

  • Why all of a sudden has one of my apps (Condition Report App) only displaying at the top right hand corner it is a quarter of the size it should be, i have tried setting my ipad back to factory settings and this hasnt helped some please help??? :)

    One of my apps (condition report app) has decided to only display on the top right hand corner which is only a quarter of the screen, not sure what has happened as i have not changed any settings went to go into it one day and it was just like it.
    Please help!!!! Thanks Kristy

    Do you have the most up-to-date version of the app? Did you upgrade to iOS 6? Did you check to make sure that the developer has updated the app for the new OS? Have you tried resetting your device by pressing and holding the Home button and power button until the silver apple appears? Have you tried uninstalling and re-installing the app?

  • HT1414 I'm trying to restore from an earlier backup but my iphone only shows the most recent. I'm on Windows Vista and found the backup folder. If I delete the recent files, will it force the iPhone to backup from the next older file?  Why doesn't it show

    I'm trying to recover a file and the app company said to restore from an earlier backup.  My iPhone only shows the most recent backup.  I've been searching the net for answers - I found the back up file and date sorted them (over 6mb of files).  How can I get my iPhone to restore from an earlier backup? 
    I am on Windows Vista so I don't have Time Machine. 
    I have backed up the backup folder so if I mess it up, I have it in a separate place.
    Can I just delete all the files with todays date in that backup folder and have it forced to the next oldest date?
    Why doesn't the iPhone show a list of the least several backups.
    Info:
    iPhone 4S
    Software version  5.1.1
    Backed up to computer through iTunes (not iCloud)

    As you backup the iPhone in iTunes, it overwrites the last backup. Files are kept as they are changed, so that would explain how you get different dates in your backup folder. The only backups that are saved and not overwritten are the ones done just prior to a restore. You do have the option to go back in time on a Windows computer, however depending on the last time you set a restore point in Windows, it could be back further than you are willing to go.

  • My device only displays the Diagnostic Mode screen. Don't metter what I do. I've tryed to update itunes and reestore with latest software a few times, but it always comes back on the Diagnostic Mode screen. What's wrong?

    My device only displays the Diagnostic Mode screen. Don't metter what I do. I've tryed to update itunes and reestore with latest software a few times, but it always comes back on the Diagnostic Mode screen. What's wrong?

    Hi sayla,
    When you reloaded your software did you do a clean reload (deleting all data)? http://bbry.lv/bpv7DT
    If so, you might try doing a resettofactory using the following instructions. http://bit.ly/fMW9I4 This will reset to factory default.
    -FS
    Come follow your BlackBerry Technical Team on Twitter! @BlackBerryHelp
    Be sure to click Kudos! for those who have helped you.
    Click Solution? for posts that have solved your issue(s)!

  • HT4623 hi, I tried restoring my ipad 4 using the itunes syncronised with my laptop, after erasing all application on he ipad the ipad cannot turn on again.  It is only displaying the itunes image on the screen.  how do I resolve thois?

    my ipad 4 cannot work again after trying to restore it using te itune application syncronised with my laptop.  After all files/data on the ipad have been erased it cannot start to work again.  It only displayed iunes icon on the screen

    Try placing the iPad in Recovery Mode on your own and restore again.
    Recovery mode - Support - Apple

  • HT4061 my iphone will not do anything...i tried to restart and reset......the phone only displays the apple logo.

    my iphone 4 will not do anything....i tried restarting and resetting....the phone only displays the apple logo.

    Hello there, Faustinamarfo.
    The following Knowledge Base article provides some troubleshooting steps for your issue:
    iPhone: Hardware troubleshooting
    http://support.apple.com/kb/TS2802
    Particularly:
    Display has no backlight or dark screen
    Toggle the ringer switch to see if the unit vibrates. If it does, it could be that iPhone is getting power, but is not displaying any image.
    Try turning iPhone off and then on again.
    While connected to the iPhone charger, try to reset the iPhone.
    If the low-battery screen appears, charge the iPhone.
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • Iphone 5 cant be restored, it shows unknown error -1 while trying to restore and it only display connect to Itune

    Iphone 5 cant be restored, it shows unknown error -1 while trying to restore and it only display connect to Itune

    Greetings ayokunlefromlos angeles,
    Welcome to the Apple Support Communities!
    I understand that when attempting to restore your iPhone you receive an error and your iPhone shows the Connect to iTunes screen. To begin troubleshooting, I would suggest manually placing your iPhone in recovery mode and attempting the restore. Please follow the instructions located in the attached article to complete this process. 
    If you can't update or restore your iPhone, iPad, or iPod touch - Apple Support
    Cheers,
    Joe

  • I bought my iPhone5 4 months ago and now the camera is not working, it only displays black in the screen. I've tried reset, restore for how many times but still the problem is not being resolve. Any help from you Apple team?

    I bought my iPhone5 4 months ago and now the camera is not working, it only displays black in the screen. I've tried reset, restore for how many times but still the problem is not being resolve. Any help from you Apple team?

    There is no Apple here, this is a user to user forum.  When you said you restored, then you restore as NEW?
    If you restored as New and still the problem persiist, then it time to take a trip to the Apple store.

  • BAM Portal is only displaying one day of aggregations

    Has anyone else seen this behaviour and better still how did you resolve
    it? See
    http://connectedpawns.wordpress.com/2014/09/25/bam-is-displaying-only-one-day-of-aggregations/
    We implemented a BAM solution using BizTalk Server 2013 and Standard SQL
    server 2012 that contained an aggregation.  We set up a scheduled aggregation as
    described
    here.
    In production if we open the BAM portal and expand the Aggregations we always
    only see the most recent days data.
    In contrast the UAT environment if we look at the aggregations in the BAM portal
    we see several months of data.
    Currently can not find any difference between the database objects
    between UAT and Production i.e. the BAM_AN_All_GCTM and the SQL agent job that
    runs the package regularly. We have confirmed that all the data is present in
    the BAMPrimaryImport tables but the portal is not displaying all the data.
    Please let me know why we a seeing this difference of behaviour between our
    UAT and Production environment.

    Have you tried the BM commands -activitywindow across the two systems to verify if the aggregation durations are the same across the systems?
    Refer http://msdn.microsoft.com/en-us/library/aa560205.aspx for details on how to Get/Set the time windows on Activity/RTA Aggregations.
    Regards.

  • Certain sites are only displaying as long rows of �s - how can this be fixed?

    Quite a few sites or parts of a site - i.e. the captcha on tinypic.com - are only displaying as very one very long, horizontally scrolling row of question marks in black diamonds (�). These sites load perfectly in Safari on my laptop, or on Firefox on my Windows desktop. There are no error messages displayed.

    How much data is being backed-up from each Mac?  (see what's shown for Estimated size of full backup under the exclusions box in Time Machine Prefs > Options).
    Is there any other data on your Time Capsule, besides the backups?
    Most likely, there just isn't room.  Time Machine may be trying to do a very large (or full) backup of one or both Macs, and can't.  Since it won't ever delete the most recent backup, there has to be enough room for one full backup plus whatever it's trying to back up now, plus 20% (for workspace).
    Also see #C4 in Time Machine - Troubleshooting for more details.

  • My itouch will only display a white screen, is this fixable? help!

    My i touch was working absoluty normally, then one day it would only display a white screen. I can still see it on my computer however it is showing that the memory has been wiped. I tried to restore it to its original settings, but it still displays the same white screen. I have drained the battery fully, and tried holding the buttons down for 10 seconds. Nothing is working and im now confused. Can anyone advise me please? thank you.

    When restoring an iPod to factory defaults/new iPOd does not solve a proble it is most likely due to a hardware problem.  I would make an appointment a the Genius Bar of an Apple store.

  • Problem with Flash videos. They are only display in "Private Browsing" mode, in Safari 5.1.7

    The symptoms is: The flash videos are only display with a full red bar and nothing happen, no video no sound nothing. The Flash player was upgrade with 11.2.202.235. before safari 5.1.7. I have an iMac with SL, and a Macbook with SL too. However after I upgraded safari 5.1.7 the flash videos are not display correctly, (only videos). The same happen in both computers.
    I need to tell you that I follow all the possible recommendations that I founded in internent. I uninstall flash pug-in many times. I restore both. I switch many buttons and options like "reset safari", "empty cahe", "block pop-up windows", "enable java-script", "enable java". I turn off and on the firewall. I switch all the options in the flash player plug in preferences. And nothing. I turn on and off the plug ins. In fact I tried all the possibilities in the preferences menus from the programs.
    In one occasion I had a glimpse of functionality for only one hour without problems after I reinstall safari from the Apple website, but only worked until I turned off the computer. The next day was the same problem.
    After I fought with safari 5.1.7 and the plug-in flash player 11.2.202.235. Now I noticed something wired, only when I switch the "Private browsing" option in safari is when the videos are displayed correctly.
    The same videos work perfectly in Firefox.
    Some Suggestions?

    Thank you everybody, the problem was corrected in a unexpected way, I decided no to pay attention to the problem after a week fighting with that. I was navigating in a private browsing for two days. I turned the private browsing off again the next Monday, after a week I noticed that all the videos were display correctly, I do not have the problem again. That was wired because at the same time in the laptop everything is ok too. I have my extensions ON, Block Pop-up windows, In Flash payer all the options in ask....something. Only the option Disable Java script in not activated, only when I activate that option all videos are not display.
    I think maybe I updated the computer and maybe something happened in the middle. I always update my imac and my macbook at the same time. There is a Flash removal security update in may 14. Maybe that fixed the problem.
    Thanks to everybody, everything is ok now however I wanted to know what was the problem.

Maybe you are looking for

  • MS-6191 256mb PC100

    Hello all, Recently I bought a 256mb PC100 stick to install on my MS6191 but the bugger doesn't want to boot with it. According to the manual the board can take 256mb per bank upto 512mb max on 2 banks.The new stick is tested and found ok in another

  • My gal's macbook is acting up?

    Hey there, this is my first time on this forum so please bear with me. My wife's macbook is only 2 months old and today she was unable to use the number zero on the keyboard. Also, it acted as if it were possessed and would type by itself. She has ne

  • Got new router, now powerbook G3 pismo wont connect to it.

    asked cable company to replace router as i was paying for 60 meg connection but due to moving my router to connect to my dreambox i realised that the router only had 802.11g wifi and so my computer wasnt able to connect fast enough to use the connect

  • Technical spec objective

    Hi, Here i get a query about the technical spec. i.e if i received a functional spec on payroll to give report  to separate based on status(active/past/old) . then how  can i choose only those pernrs ?. any specific fields for selecting those ?. Than

  • PSE 11 Date, time & star option under photo in organizer missing

    I was watching a tutorial about PSE 11 and then noticed that under my photo in the organizer I do not see the date, time, & star option.  Do I have to turn something on to see them.  Also I do not see a place under the photos to put a caption.  I'm u