Skip to content

Instantly share code, notes, and snippets.

@pepet96
Created November 6, 2013 04:46
Show Gist options
  • Save pepet96/7331054 to your computer and use it in GitHub Desktop.
Save pepet96/7331054 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
import java.io.*;
class BonusWage {
public static void main (String [] args ){
Scanner input = new Scanner(System.in);
int hours, extrahours;
double wagerate,total,bonus;
System.out.println("Enter your wage rate: ");
wagerate = input.nextDouble();
System.out.println("Enter the amount of hours you worked: ");
hours = input.nextInt();
extrahours = hours -30;
if (hours > 30) {
bonus = extrahours*(wagerate*1.5);
total = bonus + ((hours-extrahours)*wagerate);
System.out.println("Your wage will be: " + total);
}
else if (hours >= 0) {
total = wagerate*hours;
System.out.println("Your wage will be: " + total);
}
else if (hours < 0) {
System.out.println("That is not possible!");
}
}
}
@edolopez
Copy link

Recomiendo que en los condicionales explícitamente pongas el rango: Por ejemplo (hours >= 0 && hours <= 30) para delimitarlo mejor y no pase algo raro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment