Total members 11890 |It is currently Fri Apr 19, 2024 7:29 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





If statement help:
I need help with this. I am trying to get people with skill level 2 and 3 to have the option to add medical, dental or disability at a deductible of 32.50 for medical, 20 for dental and 10.00 for disability. the code I have so far is this:
Code:
import javax.swing.JOptionPane;
public class Pay
{
  public static void main(String[] args)
  {
    String hoursString, skillLevelRateString, skillLevelString;
   
    double hoursWorked = 0;
    double regularPay = 0;
    double overtimePay = 0;
    double skillLevelRate = 0;
    int skillLevel = 0;
   
    final int SKILL_ONE = 1;
   final int SKILL_TWO = 2;
   final int SKILL_THREE = 3;
   final String OPTION_ONE = "Medical insurance";
   final String OPTION_TWO = "Dental insurance";
   final String OPTION_THREE = "Long-Term disability insurance";
    final double LEVEL_ONE_RATE = 17.00;
    final double LEVEL_TWO_RATE = 20.00;
    final double LEVEL_THREE_RATE = 22.00;
    final double OPTION_ONE_RATE = 32.50;
    final double OPTION_TWO_RATE = 20.00;
    final double OPTION_THREE_RATE = 10.00;
   
   
    hoursString = JOptionPane.showInputDialog(null,
      "How many hours did you work this week?");
    hoursWorked = Double.parseDouble(hoursString);
   
    skillLevelString = JOptionPane.showInputDialog(null,
    "What skill level are you?" + "\nEnter Skill level 1, 2 or 3");
    skillLevel = Integer.parseInt(skillLevelString);//corrected with help   
    switch(skillLevel)
    {
       case 1:
      skillLevel = SKILL_ONE;
      skillLevelRate = LEVEL_ONE_RATE;
      break;
      
      case 2:
      skillLevel = SKILL_TWO;
      skillLevelRate = LEVEL_TWO_RATE;
      break;
      
      case 3:
      skillLevel = SKILL_THREE;
      skillLevelRate = LEVEL_THREE_RATE;
      //etc   
   }
    if(hoursWorked > 40)
    {
      regularPay = 40 * skillLevelRate; //skillLevelRate allows for changes
      overtimePay = (hoursWorked - 40) * 1.5 * skillLevelRate;
    }//thanks for help here
    else
    {
      regularPay = 40 * skillLevelRate;
      overtimePay = 0.0;
    }
    JOptionPane.showMessageDialog(null, "Regular pay is " +
       regularPay + "\nOvertime pay is " + overtimePay);
       System.exit(0);
      {
         
   
   
  }
}
}

So far I can only do regular pay and overtime pay calculation with the full amount of hours/pay shown as so. I want to use an if statement but I do not know how to add the 'and' and 'or' in there if I need to at all please help. I want to be able to have a person add in their hours and what skill level they are currently, then add any benefits they may want. In the end they should see what they make a week after deductions. Thank you for any input.




Author:
Newbie
User avatar Posts: 2
Have thanks: 0 time

the and in java if statement is like the following

Code:
if(x=5 && y = 6)
  {
      System.out.println("Am here " ) ;
   }   


the or is (' || ' ) instead of &&

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

Thanks :grin:


Author:
Newbie
User avatar Posts: 2
Have thanks: 0 time
Post new topic Reply to topic  [ 3 posts ] 

  Related Posts  to : Need help with if statement
 difference between break statement and a continue statement     -  
 difference between a while statement and a do statement     -  
 while Statement in php     -  
 The do...while Statement     -  
 Using the for Statement     -  
 PHP if statement and else if     -  
 Define statement     -  
 JOptions and If - Else statement     -  
 For statement without all three statements     -  
 global statement in php     -  



cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com