// a simple module to provide quick calculations to figure out hourly/monthly/yearly income rates when given one of them.
function salaryCalculator(){
this.cash = 0;
// 40 hour week * 52 weeks per year = 2080
this.setHourly = function(c){
this.cash = this.get2Decis(c * 2080);
}
this.setYearly = function(c){
this.cash = c;
}
this.setMonthly = function(c){
this.cash = this.get2Decis(c * 12);
}
this.getHourly = function(){
return this.get2Decis(this.cash / 2080);
}
this.getYearly = function(){
return this.cash;
}
this.getMonthly = function(){
return this.get2Decis(this.cash / 12);
}
this.get2Decis = function(n){
return Math.floor(n * 100) / 100;
}
}
var n = new salaryCalculator();
n.setHourly(12);
console.log("Current minimum wage of " + n.getHourly() + "/hr is " + n.getMonthly() + " per month, and " + n.getYearly() + " per year.");
Wednesday, March 22, 2023
Coding Challenge #29 Salary Calculator
Subscribe to:
Post Comments (Atom)
Coding Challenge #54 C++ int to std::string (no stringstream or to_string())
Gets a string from an integer (ejemplo gratis: 123 -> "123") Wanted to come up with my own function for this like 10 years ago ...
-
I NEEDS MY JAVASCRIPT PLEASE :) Open txtcode .txt Save as .gct Please click the blue cheat code title to activate it, a...
-
Naruto Personality Quiz Please enable javascript ☯ Which Naruto Character Are You?
-
Useful for extensions that want to prevent event listeners from being attached or modify prototypes or functions, generally to defeat click...
No comments:
Post a Comment