Making a double into a constant...how do i do it?

i'm writing a program for my comp 1900 class to compute a salary and print out a paycheck and stub for each employee the info is entered in for.
i need to make the salary a constant (i think)....is there a way to make the user-inputed number into a constant?
i have salary = scan.nextDouble(); and i need to make that salary into a constant.
i have most of the program written, but i re-read the instructions and found some stuff that needs fixing, this being one of them.
thanks much.

import java.util.Scanner;
public class Paycheck
public static void main (String [] args)
Scanner scan = new Scanner (System.in);
double workedHours, overtimeHours, sSecurity, medicareTax, federalWithhold, paycheck;
double health, dentalInsurance, visionInsurance;
double salary = 0, deductions, rate = 0
String employeeType, employeeName, fulltime, parttime, yes, no, fedHold, healthIns, chosenHealth = "boo", minimal;
String standard, premium, dentIns, visIns;
//fix the address to its correct form.
final String COMPANY_LOGO = "Best Widgets, Inc" + "/nADDRESS";
//computing salary
System.out.println ("Enter the name of the employee.");
employeeName = scan.nextLine();
System.out.println ("Is this employee part time or full time? parttime or fulltime");
employeeType = scan.next();
if (employeeType.equals("fulltime"))
System.out.println ("Please enter the number of hours worked, not including overtime.");
workedHours = scan.nextDouble();
System.out.println ("Please enter the number of overtime hours worked this pay period.");
overtimeHours = scan.nextDouble();
System.out.println ("Enter the salary rate for " + employeeName);
rate = scan.nextDouble();
// initialize and declare constant for adding deductions together later
salary = (workedHours + (overtimeHours * 1.5)) * rate;
else
if (employeeType.equals("parttime"))
System.out.println ("Please enter the number of hours worked.");
workedHours = scan.nextDouble();
System.out.println ("Enter the salary rate for " + employeeName);
salary = (workedHours * rate);
else
System.out.println ("You entered an incorrect value.");
//computing deductions
sSecurity = (.062 * salary);
medicareTax = (.015 * salary);
if (employeeType.equals("fulltime"))
federalWithhold = (.095 * salary);
else
System.out.println ("Did you choose to have federal income withhold? yes or no");
fedHold = scan.next();
if (fedHold.equals("yes"))
federalWithhold = (.095 * salary);
else
federalWithhold = 0;
//optional deduction items for ALL employees
System.out.println ("Is medical health insurance taken out of the employee's salary? yes or no");
healthIns = scan.next();
if (healthIns.equals("yes"))
System.out.println ("Did the employee chose the minimal coverage plan, standard coverage plan,"
+ " or premium coverage plan? minimal, standard, or premium");
chosenHealth = scan.next();
if (chosenHealth.equals("minimal"))
health = (salary - 54.00);
else
if (chosenHealth.equals("standard"))
health = (salary - 82.00);
else
health = (salary - 110.00);
else
health = (salary - 0);
System.out.println ("Did this employee choose to take Dental Insurance? yes or no");
dentIns = scan.next();
if (dentIns.equals("yes"))
dentalInsurance = (health - 27.62);
else
dentalInsurance = (health - 0);
System.out.println ("Did this employee choose to take vision insurance? yes or no");
visIns = scan.next();
if (visIns.equals("yes"))
visionInsurance = (dentalInsurance - 7.88);
else
visionInsurance = (dentalInsurance - 0);
//deductions added.
deductions = (sSecurity + medicareTax + federalWithhold + visionInsurance);
System.out.println ("Your salary for this pay period is " + (salary - deductions));
what do i change the 2 bolded items to so i don't get an error saying they haven't been initialized (even though they are later on IMO) and i don't get a negative number when the math is done....i just executed the program and input 27.50 for rate and 80 hours worked with 12 OT hours. i should have come out with $2896 - whatever deductions i "picked" but i came out with -396.00 or something close.

Similar Messages

  • Iphone 4 is making me double-tap the screen and is reading everything to me. How do I make that stop?

    My grandmother has an iphone 4. She doesn't know what happened but suddenly it started to read her everything and is making her double-tap her screen. How do I get that setting removed?

    This has to do with accessibility. You can triple-tap the home button to get it off for right now. Then go into Settings>General>Accessibility and turn off VoiceOver. If you have difficulty getting there, to use VoiceOver, you tap once to select an item, double-tap to activate it and swipe with 3 fingers to scroll.

  • I want to bring in text from Word (and the web) that is already hyperlinked into InDesign. How do I do it while keeping the links active?

    I want to bring in text from Word (and the web) that is already hyperlinked into InDesign. How do I do it while keeping the links active?
    Whenever I copy/paste from web or Word it removes the hyperlinks.  And when I try to do it by "Place"ing a Word document into my InDesign project it keeps the formatting with it, the rectangles around the text.
    I have the latest version of InDesign.
    Any help is appreciated. 

    Copy-and-paste may not include formatting. A regular import using Place is the best way.
    The rectangles around the hyperlinks are just to indicate they are links -- they do not print, but they do show up in your PDF.
    You can remove them by double-clicking the hyperlink in the Hyperlinks panel and select "Invisible Rectangle" as type.
    Typically, Word hyperlinks are formatted -- blue text, underline -- with a Character Style. If you want to remove or change the formatting, all you have to do is change the character style. My experience, though, is you must check all hyperlinks because for no apparent reason sometimes they appear in the document without the character style.

  • Double into an int?

    Hi,
    Bit of a noob question, can anybody tell me how to parse a double into an int?
    many thanks

    Of course, if you want behavior other than truncation, look at the Math class.
    double myDouble = 3.97;
    int myInt = (int)Math.round( myDouble ); // myInt == 4
    int myInt = (int)Math.floor( myDouble ); // myInt == 3
    int myInt = (int)Math.ceil( myDouble ); // myInt == 4RD-R
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • The hard disc of my laptop has crashed and i lost all the data. Now I want to take back up of my I phone and transfer contacts , messages and music back into my laptop , how can I do that. Pl help

    The hard disc of my laptop has crashed and i lost all the data. Now I want to take back up of my I phone and transfer contacts , messages and music etc back into my laptop , how can I do that. Also let me know how I can transfer the contacts into Windows contacts from I phone. Pl help

    Your content will only be where you put it.  It has always been very basic to always maintain a backup copy of your computer.
    You can transfer itunes purchases from your iphone: File>Device>Transfer purchases.
    You can import your pics taken with the iphone as you would with any digital camera.
    You can e-mail the other pics to yourself, they will never be of the original quality.
    You can out a unique contact and calendar entry on the computer.  You should get the option to merge the data when you sync.

  • The app icons and font on my iPhone 4 just went to massive making it difficult to even scroll how can I change it back, where do I go which menu? Thanks in advance

    The app icons and font on my iPhone 4 just went to massive making it difficult to even scroll how can I change it back, where do I go which menu? Thanks in advance

    Next time you accidentally use 3 fingers it will zoom again. Unless you need the feature you're better to turn it off

  • I have a black box showing up on my desktop that I cannot get rid of which is preventing me from getting into Itunes. How can I get rid of it?

    I have a black miniplayer box that has shown up on my desktop that I cannot get rid of that is blocking me from getting into ITunes.
    How can I get it off ?

    Reboot and see whether it goes away.

  • Why has iTunes seperated a album which I have copied over from my external hard drive into iTunes? How can you pull all the songs back together into one album again?

    Why has iTunes seperated a album into indevidual songs, which I have copied over from my external hard drive into iTunes? How can you pull all the songs back together into one album again?

    Steve MacGuire a.k.a. turingtest2 - iTunes & iPod Hints & Tips - Grouping Tracks Into Albums - http://www.samsoft.org.uk/iTunes/grouping.asp (older post on Apple Discussions http://discussions.apple.com/message/9910895)
    Quick answer:  Select all the tracks on the album, File > get info, and either give them all a single "album artist", or check the "compilation" flag (as in https://discussions.apple.com/message/17670085).
    If these are from multiple-CD sets you may also need to enter the appropriate information in the disc number fields.  If they are not a multiple CD set you still need to make sure the disc number fields are set correctly or all empty.

  • The ipod is disabled, when i plug it in to my pc it says it can not connect without the passcode being put into the ipod, how do i fix it?

    the ipod is disabled, when i plug it in to my pc it says it can not connect without the passcode being put into the ipod, how do i fix it?

    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

  • HT4060 iPad will not charge if hooked by USB to pc or plugged into wall.  How do I know if the problem is with iPad, cable or power adapter.  I have a 12, 10 and 5W adapters no success with any.  Only one lightening cable so can't swap cables.

    iPad will not charge if hooked by USB to pc or plugged into wall.  How do I know if the problem is with iPad, cable or power adapter.  I have a 12, 10 and 5W adapters no success with any.  Only one lightening cable so can't swap cables.

    I'm sorry but this is too funny to pass up. 

  • Attempted to sync IPhone 3gs several times, didn't work. Finally did, saved it and then went into recovery. How do I access the saved information?

    Attempted to sync IPhone 3gs several times, didn't work. Finally did, saved it and then the phone went into recovery. How do I access the saved information prior to recovery?
    Thanks

        Hello Snosilla! I'm so sorry for all the confusion and for all the time taken to activate service with us! I do see that the iPhone 5c is $99.99 right now. The iPhone 5s is actually $199.99. There's no need to call Pam anymore, we can take over from here.
    I've followed you in the forums. Please accept me, and follow me back. Then, send me a Direct Message and I can look into this for you. If you do not have an active line yet, I may need to get you through to our activations department, but I will do all I can!
    Thank you!
    ChristinaB_VZW
    VZW Support
    Follow us on Twitter @VZWSupport
    VZW Support

  • I inserted  SD card into CD slot how do I get it back out

    Inadverdently inserted SD card into CD slot how do I get it back out help please

    Happened to me too. Just before I went on holiday and I was clearing off my SD card for my camera. I left it there until I got back (having to buy a new card at the airport) then did a quick search. Found this clip on youTube featuring an L-shaped piece of cardboard trick which worked perfectly for me on second attempt.
    You've got to really blame Apple for the design of the machine when you consider the sheer amount of people who have made this mistake. At least I won't make it again.
    J

  • I'm trying to update my iPhone and it's connected to my computer through the usb port, but my iPhone is still saying to plug it into iTunes. How do I fix it?

    I'm trying to update my iPhone and it's connected to my computer through the USB port, but my iPhone is still saying to plug it into iTunes. How do I fix it?

    This is what my screen looks like.

  • When I transferred my iPhoto from macbook to iMac it created double events for each, how do I correct this?

    When I transferred my iPhoto from macbook to iMac it created double events for each, how do I correct this?

    How did you do it?
    Here's what should work:
    To move an iPhoto Library to a new machine:
    Link the two Macs together: there are several ways to do this: Wireless Network,Firewire Target Disk Mode, Ethernet, or even just copy the Library to an external HD and then on to the new machine...
    But however you do choose to link the two machines...
    Simply copy the iPhoto Library from the Pictures Folder on the old Machine to the Pictures Folder on the new Machine.
    Then launch iPhoto. That's it.
    This moves photos, events, albums, books, keywords, slideshows and everything else.

  • In Contacts, I don't have any duplicates, but in iMessage contacts on iMac in Mountain Lion, the contacts it provides for a new message are all doubles. Why and how can I fix?  Thx.

    In Contacts, I don't have any duplicates, but in iMessage contacts on iMac in Mountain Lion, the contacts it provides for a new message are all doubles. Why and how can I fix? 
    I also notice that each contact says iCloud in it twice, but when I go to iCloud.com, there are no duplicates either. Help..

    mdd770,
    Try Contacts>Preferences...>Accounts...remove {-}/re-add {+}your iCloud account.
    If that is not successful, follow the steps listed in iCloud: Troubleshooting iCloud Contacts.

Maybe you are looking for