RgrWalker
asked on
Creating a Separate Method to Calculate
How would I go about writing a program that displays a salary of an employee or emplyoyee's and does the calculations in a separate method and returns the result to be displayed?
Very new to Javascript and Expert Exchange.
Thanks for the help
Very new to Javascript and Expert Exchange.
Thanks for the help
typo on my doAdd and doMult functions. should be:
function doAdd(val1, val2)
{
return val1+val2;
}
function doMult(val1, val2)
{
return val1*val2;
}
function doAdd(val1, val2)
{
return val1+val2;
}
function doMult(val1, val2)
{
return val1*val2;
}
ASKER
So if it had to display the weekly salary who earned ## per hour and worked 40 hours and 13 overtime hours at a time and a half wage how would it look?
This is what I've come up with, I'm trying to figure out how I get it to display and calculate in a separate method.
public class Salary
{
public static void main(String[] args)
{
double Wage=25.00;
double numberOfHoursWorked=40;
double OverTimeHoursWorked=13;
double WeeklySalary=OvertimePay+( Wage*numbe rOfHoursWo rked);
double OvertimePay=OverTimeHoursW orked*(Wag e*1.5);
System.out.println("Weekly Salary: " +Weekly Salary);
}
}
This is what I've come up with, I'm trying to figure out how I get it to display and calculate in a separate method.
public class Salary
{
public static void main(String[] args)
{
double Wage=25.00;
double numberOfHoursWorked=40;
double OverTimeHoursWorked=13;
double WeeklySalary=OvertimePay+(
double OvertimePay=OverTimeHoursW
System.out.println("Weekly
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Worked great, the only change I made were removing the Colan in this line....
System.out.println("Weekly Salary: " +Weekly Salary);
Thank you for your help
System.out.println("Weekly
Thank you for your help
<form name="calc">
<input type="input" id="value1">
<input type="input" id="value2">
=
<input type="input" id="answer">
<input type="button" value="do calc" onClick="showCalc()">
</form>
then your script would be:
<script>
function showCalc()
{
val1 = document.getElementById("v
val2 = document.getElementById("v
document.getElementById("a
document.getElementById("a
}
functino doAdd(val1, val2)
{
return val1+val2;
}
functino doMult(val1, val2)
{
return val1*val2;
}
</script>
-Trevor