Skip to content

Instantly share code, notes, and snippets.

@uraimo
Last active November 7, 2022 14:38
Show Gist options
  • Save uraimo/43229213acdd4aac77bece12b26ff4cc to your computer and use it in GitHub Desktop.
Save uraimo/43229213acdd4aac77bece12b26ff4cc to your computer and use it in GitHub Desktop.
Interview question [entry-level,java,finance]: solve and comment on what's wrong with this sample
// Calculate the tax from the amount as you would do in a real world scenario.
class TaxMan{
//Return the tax as percentage of the amount plus penalty
private static double calcTaxes(long amount, int perc, double penalty){
//fill here
}
public static void main(String args...){
System.out.println(calcTaxes(1,10,0.1) == 0.2);
System.out.println(calcTaxes(1,20,0.02) == 0.22);
System.out.println(calcTaxes(1,5,0) == 0.05);
System.out.println(calcTaxes(1,20,0.01) == 0.21); //If it breaks here, explain why.
System.out.println(calcTaxes(1,10,0) == 0.1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment