in just basic There are 2 employees Write a program with nes
in just basic.
There are 2 employees. Write a program with nested loops, to ask the yearly salary of each employee for 2 years. Your program should keep track of the highest salary, lowest salary, and calculate the average salary of each employee.
this is what i got so far, but i cant figure out how to get averageSalary to work.
min=999999999999
max =0
for employee = 1 to 2
for year = 1 to 2
print\"enter salary for employee\"; employee,\"for year \";year
input salary
totalSalary = totalSalary + salary
if (salary < min) then
min = salary
end if
if (salary > max) then
max = salary
end if
next
averageSalary = (totalSalary / 2)
print\" totalsalary is: \" ;totalSalary
print \"average salary is: \";averageSalary
print \"min is: \";min
print \"max is: \";max
next
Solution
for employee 1to 2
{
for year 1to 2
{
Print \"enter the salary of employee for year\", year;
total salary=total salary+salary;
If salary<min
min=salary;
elseif salary> max
max= salary;
}
average =totalsalary/2
Print \" total salary\"
Print \"average salary\"
Print min
Print max
}

