How to initialize this correctly?

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));
whenever i execute this program as is, i get negative numbers for the output of the salary...which doesn't happen. It's supposed to be bi-weekly...so i put in 80 hours as the hours worked. then 12 hours as overtime. that makes 98 total hours (12 * 1.5 + 80) multiplied by 27.50 = 2000 something. that's what it SHOULD BE. when i put that stuff into the program, after subtracting the deductions it comes out with -300 something dollars...the gov doesn't take over 2k on a paycheck that is only 2k lol.
i have salary = 0; at the top to initialize it to something. i tried doing double salary = scan.next(); and double rate = scan.next(); on the two that applies to, but i get the error saying it wasn't initialized on the other parts that use salary.
what AND where do i need to initialize and declare rate and salary to to make this work properly? this is a project i have due TOMORROW and i have 4 hours i can work on it tonight. i also have to print out a paycheck and stub at the end of the code to make it "look realistic"...which i think will be hard considering i have nothing to look at for an example.
thanks much if you can help.

Your code is reason enough to hope for government-supplied universal health insurance coverage. If you're looking for the insurance agent who sold your company this policy, he's probably in South America under an assumed identity. Please see comments below:
import java.util.Scanner;
public class Paycheck2
    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); //***** yikes!!!! *****
            else if (chosenHealth.equals("standard"))
                health = (salary - 82.00); //***** yikes!!!! *****
            else
                health = (salary - 110.00); //***** yikes!!!! *****
        else
            health = (salary - 0); //***** yikes!!!! *****
        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);  //***** yikes!!!! *****
        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);  //***** yikes!!!! *****
        //deductions added.
        deductions = (sSecurity + medicareTax + federalWithhold + visionInsurance);
        System.out.println("Your salary for this pay period is "
                + (salary - deductions));
}

Similar Messages

  • How to initialize this collection?

    Hello:
    Is it correct?
    In a package I have defined
    TYPE REG_SITUACION_TRIB IS RECORD (
    SITR VARCHAR2(50),
    ESTADO_SITUACION Varchar2(1)
    TYPE TABLA_SITUACION_TRIB IS TABLE OF REG_SITUACION_TRIB INDEX BY BINARY_INTEGER;
    g_tabla_situacion_trib TABLA_SITUACION_TRIB;
    And in the package body, inside a function
    v_cont_sit:=0;
    FOR v_cursor IN c_cursor( parameter1 )
    LOOP
         v_cont_sit:= v_cont_sit + 1;
         g_TABLA_SITUACION_TRIB( v_cont_sit ).SITR := V_cursor.SITR;
         g_tabla_situacion_trib( v_cont_sit ).ESTADO_SITUACION:='S';
    END LOOP;
    Am I properly initializing the collection g_tabla_situacion_trib?
    Do I need an EXTEND method?
    If cursor returns no results, is g_tabla_situacion_trib variable initialized to NULL?
    Thanks

    If cursor returns no results, is g_tabla_situacion_trib variable initialized to NULL?Contrary to previous replies, No. It is an empty collection, not the same. See below.
    Also, if you going to do this:
    v_cont_sit:=0;
    FOR v_cursor IN c_cursor( parameter1 )
    LOOP
    v_cont_sit:= v_cont_sit + 1;
    g_TABLA_SITUACION_TRIB( v_cont_sit ).SITR := V_cursor.SITR;
    g_tabla_situacion_trib( v_cont_sit ).ESTADO_SITUACION:='S';
    END LOOP;Why not just bulk collect into a collection with a type of cursor%rowtype?
    using the limit clause if necessary (but [being aware of SQL%NOTFOUND|http://www.oracle.com/technology/oramag/oracle/08-mar/o28plsql.html])
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> CREATE OR REPLACE PROCEDURE p3
      2  AS
      3    CURSOR c1
      4    IS
      5      SELECT SYSDATE dt
      6      FROM   DUAL;
      7    --
      8    TYPE t1 IS TABLE OF c1%ROWTYPE INDEX BY PLS_INTEGER;
      9    --
    10    l1 t1;
    11    --
    12  BEGIN
    13     --
    14     IF l1 IS NULL
    15     THEN
    16         DBMS_OUTPUT.PUT_LINE('Is Null');
    17     ELSE
    18         DBMS_OUTPUT.PUT_LINE('Is Not Null');
    19     END IF;
    20     DBMS_OUTPUT.PUT_LINE('Empty collection: '||l1.COUNT);
    21     --
    22     OPEN c1;
    23     FETCH c1 BULK COLLECT INTO l1;
    24     CLOSE c1;
    25     DBMS_OUTPUT.PUT_LINE(l1.COUNT);
    26     --
    27  END;
    28  /
    Procedure created.
    SQL> set serveroutput on
    SQL> exec p3;
    Is Not Null
    Empty collection: 0
    1
    PL/SQL procedure successfully completed.
    SQL>

  • "Only Get Delta Once" - How to use this correctly?

    Hi folks,
    we are currently facing the following situation:
    We have a data source only being able to deliver full update.
    That's why we proceed as follows:
    1.) Full-Load with Infopackage to PSA
    2.) Delta-Load with DTP from PSA to first-level-DSO (write-optimized)
    3.) Delta-Load with DTP from first-level-DSO to second-level-DSO (standard-DSO). As the activation aggregates all duplicate entries, we are therefore able to deliver a delta to all following data targets (e.g. infocubes)
    What we are now wondering about how to use the flag "Only Get Delta Once" which is available in all Delta-DTPs. The help explains it should be used when creating snapshot-scenarios like ours as each request is only delivered once, even if it gets deleted in the data target.
    But what other benefit would we have when setting this flag? As I mentioned, the snapshot-scenario also works without this flag...
    Could anyone perhaps provide me some more details about this flag and where it should be used?
    Thanks & regards
    bivision

    Hi,
    If you select the option 'Only get delta once', then every request in the PSA will only be loaded into the Data target once. For example. If you load a full request into the PSA through an InfoPackage and then load it to the Cube. In a snapshot scenario, when the new full load comes to the PSA you will need to delete the previous request from the cube before loading the new request.
    But if you delete the previous request from the cube, and not from the PSA - and if you haven't checked the 'Only get delta once' flag, when you execute the DTP, it will load both previous and the new requests from the PSA to the cube. In order to avoid this you have 2 options:
    1. You can delete a request from the PSA after every successful load into the Cube OR
    2. You can check the 'Only get delta once' flag in the DTP so that it won't load any request it has loaded into the cubes previously even if it was deleted from the cube.
    Using the second option de-couples the PSA maintenance from your regular data loading and also saves you an additional step of deleting the PSA request in your process chain.

  • How to initialize variable? (ArrayList String [])

    How to initialize this variable correctly, without getting a type safety warning?
    ArrayList<String>[] var = ?
    Thanks & Best regards,
    Kristian
    Message was edited by:
    Kriskra

    I need to use an array in this case... Thanks for
    your advice anyway...And the answer still is arrays and generics don't mix so your request is impossible without ignoring the warning.
    Try@SuppressWarnings("unchecked")
    ArrayList<String>[] var = new ArrayList[10];

  • I purchased photoshop elements 8 on line in 2010. I recently switched to a new desktop computer. Photoshop asked for my serial number. I entered the correct serial number (obtained from Adobe). It says it is invalid. How do I get this corrected so I can u

    I purchased photoshop elements 8 on line in 2010. I recently switched to a new desktop computer. Photoshop asked for my serial number. I entered the correct serial number (obtained from Adobe). It says it is invalid. How do I get this corrected so I can use the product I purchased?

    Hi Rosera,
    This is bad and I am sorry to hear that you are running into these issues.
    Let me connect with you, so right now, the current state is that you have installed copy of PSE 8 in trial on your windows 7 machine, and when you are trying to enter the serial number from your PSE 8 Box, it is saying the serial number to be invalid?
    It might sound pretty obvious, but please make sure that you are entering the serial number correctly and of PSE 8(in case you bought a PEPE box)?
    Have you tried the steps mentioned below by Barbara?
    If possible, you can send me the serial number through PRIVATE MESSAGE and I can check it on my end that whether the serial number is indeed invalid or that the issue is with your machine?
    Regards,
    Ankush

  • I read that I can have iworks for free on my iPad if I own a copy for my computer. Is this correct, and how do I download it wit out being charged?

    I read that I can have iworks for free on my iPad if I own a copy for my computer. Is this correct, and how do I download it without being charged?

    There really is nothing more to say than what Allan has already said, but to explain just a little further, what you may have read is that once you purchase an iOS app in the app store, you do not have to purchase it again if you need to download it to another iOS device. In other words once you buy the app, you can load it onto unlimited iPhones, iPod Touches or iPads.
    You must be using the same iTunes account that you originally purchased the app with in order to download it again. But as Allan said, just because you have it on your Mac does not entitle you to download it free to your iPad.

  • Using 10.6.8, internet pdf documents not opening using Adobe Reader; how is this corrected?

    Using 10.6.8, internet pdf documents not opening using Adobe Reader; how is this corrected?  I've tried changing "sharing and permissions" to "read and write" as suggested on other help sites, but this did not correct the problem.

    I had the same problem---contacted Adobe and their service rep helped me by
    A.   Deleting  Adobe Reader from my iMac's Applications in Finder
    B.   Downloading Google Chrome browser and then
    C.   Downloading the latest Adobe Reader for Mac 10.6.8 in Google Chrome--it works
    Adobe acknowledges problem with the latest Snow Leopard update 10.6.8 and with this work around, I can open PDF's using the Google Chrome Browser.
    Is this the ideal solution---NO.  Safari is my main browser. I now have to use a separate browser for PDF's.
    Am I happy to be able to open PDF's---YES
    You can't believe the time I spent to solve this problem before calling Adobe for help. My Apple Care policy expired a month ago . As I use Photoshop Elements, I was not charged by Adobe for their help on the telephone.

  • I delete an individual message but the time I received the message is still showing next to the persons name in my inbox instead of going back into the correct date/time order. Anyone know how to fix this?

    I delete an individual message but the time I received the message is still showing next to the persons name in my inbox instead of going back into the correct date/time order. Anyone know how to fix this?

    SOLUTION
    Open "terminal" on your mac and type the following:
    defaults write com.apple.mail IgnoreSortOrderWhenSelectingAfterDelete 1
    (copy and past the whole line)
    This will stop that behaviour in mail. 
    It works on most opperating systems.
    mine is.
    Mac OSx 10.7.2 Lion
    Cheers

  • I downloaded CS6 and was told that it was possible to make a hard copy DVD for safety,is this correct and if so how is it done?.

    I downloaded CS6 and was told that it was possible to make a hard copy DVD for safety,is this correct and if so how is it done/.

    Use a DVD burning program:
    https://www.google.com/search?q=vdvd+burning+program&ie=utf-8&oe=utf-8&aq=t&rls=org.mozill a:en-US:official&client=firefo…

  • HT5557 since i updated my Apple ID with correct email address I can now only send imessages to email addresses and not iphone numbers - any idea how to fix this problem ?

    since i updated my Apple ID with correct email address I can now only send imessages to email addresses and not iphone numbers - any idea how to fix this problem ?

    You might want to try contacting Apple for assistance by going to https://expresslane.apple.com, then click See All Products and Services>iTunes>iTunes Store>Passwords & Security Questions>Lost or Forgotten Apple ID password.  They should be able to explain what's going on and help you reset the password for the old ID if necessary.  The call should be free.

  • How to supress or correct this warnning

    hi ... I have plain java program .. written using a windows with US english.... now i have to run the same jar file in a windows with japanese in it ... but when i run the jar a warning
    " Default charset MS392 not supported , ISO-8859-1 instead "
    is appearing ... I strictly dont want to this to be displayed... how to supress this warning or how to correct it
    pls help
    __raj

    You could try adding this option to your java command -Dfile.encoding=ISO-8859-1. I don't know if it will help or not.

  • Creative Cloud locked up and had to Uninstall. Upon reinstall it initializes and downloads 2/3 but then stops every time. How to remedy this?

    Creative Cloud locked up and had to Uninstall. Upon reinstall it initializes and downloads 2/3 but then stops every time. How to remedy this?

    After running cleaner tool, follow below steps :
    End all Adobe process from Task Manager .
    1) Open Control Panel and Navigate to Control Panel\Programs\Programs and Features .
    Under Program and Features list,If present remove Adobe Creative Cloud option.
    2) Open C:drive and navigate to C:\Program Files (x86)\Common Files\Adobe.
    Open Adobe folder and delete folders named Adobe Application Manager and OOBE.
    3) Navigate to C:\Program Files (x86)\Adobe.
    Open Adobe folder and if present delete Adobe Creative Cloud folder.
    4) Press Windows button (located between Ctrl and Alt buttons) along with R button together at a time , you will get a run command window.
    Type in below command and hit 'Enter' key.
    appdata
    Then navigate to Local>Adobe.
    Open Adobe folder and delete folders named AAMUpdater and OOBE.
    5) Click on the below link and download Adobe Application Manager and install the same.
    Once the installation process is completed , it will create shortcut icon on Desktop.
    Double click on it and update, it will get updated to Creative Cloud :
    http://download.adobe.com/pub/adobe/creativesuite/cc/win/ApplicationManager9.0_all.exe

  • My phone randomly doesn't ring when people call and not sound the text alert. I checked all the settings and them seem to be correct. Anyone know how to fix this?

    My phone randomly doesn't ring when people call and not sound the text alert. I checked all the settings and them seem to be correct. Sometimes it rings, many times it doesn't. I have missed several calls. Same with texts. Anyone know how to fix this?

    Symptoms
    No ringer sound
    Go to Settings > Sounds > Ringtone and select a ringtone. Does the device ring? (YES: Issue resolved) (NO: Go to step 2)
    Go to Settings> General> Reset> Erase All Content and Settings. Warning: This will delete all user data on the device. Verify that you have a backup before proceeding. Go to Settings > Sounds > Ringtone and select a ringtone. Does the device ring? (YES: Issue resolved) (NO: Go to step 3)
    Restore device using latest version of iTunes. Go to Settings > Sounds > Ringtone and select a ringtone. Does the device ring? (YES: Issue resolved) (NO: Contact Apple for service options)

  • How would I express this correctly

    How would I express this correctly?
    elseif ($row_rs['loggedinip'] != $_SERVER['REMOTE_ADDR'] AND
    now("Y-m-d H:i:s") < $row_rs['lastlogin']+120 minutes) {
    die(header("Location:
    http://domain.com/login.php"));
    else {...

    .oO(jsteinmann)
    >Its not on a unix system
    Doesn't matter. Unix timestamps also work on Windows, they
    are just one
    way to store a time code withing the range of (roughly)
    1902-2038.
    >mysql data is in a datetime format
    You could also let MySQL already return the date as a Unix
    timestamp or
    even do the entire calculation in MySQL, as already
    suggested. You could
    let MySQL return both: the normal 'lastlogin' field and
    another one with
    'lastlogin'+120 minutes or whatever. Or do the entire date
    test in SQL
    and just return a boolean value if the last login was more
    than 120
    minutes ago or not ... there are several different ways.
    Micha

  • I am using usb/my keyboard to record an original song.  I play the melody  on my keyboard but the rhythmic notation shown is not correct. i.e.  a dotted 8th and 16th pattern has rests, 32 notes,etc. and most is incorrect.  Any thoughts on how to fix this?

    I am using usb/my keyboard to record an original song.  I play the melody  on my keyboard but the rhythmic notation shown is not correct. i.e.  a dotted 8th and 16th pattern has rests, 32 notes,etc. and most is incorrect.  Any thoughts on how to fix this?

    What is your GarageBand version? Are you using the most recent GarageBand 10.0.x or an earlier version?
    I play the melody  on my keyboard but the rhythmic notation shown is not correct. i.e.  a dotted 8th and 16th pattern has rests, 32 notes,etc. and most is incorrect.  Any thoughts on how to fix this?
    The rhythmic notation in GarageBand is the best estimate, based on the length of the notes you played and the "quantize" settings. You can correct the score somewhat by adjusting the note values in the Piano Roll view and by selecting notes and picking a suitable time quantize setting in the track editor, e.g., if you wanted to play triplets, set the quantize value correspondingly:
    But I never could get GarageBand to show the dotted notes and rests correctly.
    If your main goal is to create a musical score and not to mix music, better use notation software instead of GarageBand.

Maybe you are looking for

  • FRM-41213 When calling report from a form using RUN_REPORT_OBJECT

    Hi, I get an error frm-41214:unable to connect to the report server when i am trying to call a report from a form using RUN_REPORT_OBJECT. My code is as follows: I have created a simple report using employee table such tht when i give the department

  • Booting system from an external drive; Folder with Question Mark

    Hello all. I am trying to setup an external USB hard drive as a bootable device for my Tiger install. This is on a Core Duo Mac Mini. I have successfully partitioned it using GUID into two partitions; A small 5gb partition for the minimal OSX install

  • How can I use a ranged comment marker to quickly define in and out range?

    Hi, I'm using several parts of a single clip, and they have overlapping in and out points. As I'll need to go back and grab them multiple times, I've defined these ranges by using a comment marker, then giving them a range by setting the in and out p

  • Printer determination for printing Purchase Order

    Hi, When I create Purchse Order I want to print 2 documents - Purchase order for the vendor and a check list for the stockkeeper. I created 2 different message types. When PO is for different Plants, I want to print this check list on different print

  • CRio 9014, 9116 and 9870 - serial write not working

    Hi, I am trying to read string from the text file and write to the serial port on 9870. The string are being read fine, they are getting in the Write_FIFO, the wait on IRQ passes all the bytes to the serial port. BUT I am struck, because there is not