• 0

Java Script homework help


Question

I am trying to do a homework assignment and I am having issues getting the code to work. Here is the task and then my code so far. Any help would be appreciated. 

Task: 
A retail company assigns a $5000 store bonus if monthly sales are $100,000 or more. Additionally, if their sales are 125% or more of their monthly goal of $90,000, then all employees will receive a message stating that they will get a day off. 



function Main() 
var real monthlySales; 

bonusMoney = getBonus(); 
dayoff = getdayOff(); 
getSales = monthySales(); 


function getSales(Real Ref monthlySales) 

return prompt("Enter the total sales for the month."); 
end function 


function getBonus(Real Ref monthlySales) 

If monthlySales >=100000 Then 
Println ?You get a bonus of $5,000!!!?; 
End If 
End function 


function GetDayoff(Real Ref monthlySales) 

if monthlySales >=112500 Then 
Println ? You get a bonus of $5,000!!!?; 
Println ?All employees get one day off!!!?; 
End If 
End function 

Main(); 

When I run this in the display window all I get is
...
 
 
Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Hello,

I am trying to do a homework assignment and I am having issues getting the code to work. Here is the task and then my code so far. Any help would be appreciated. 

Task: 

A retail company assigns a $5000 store bonus if monthly sales are $100,000 or more. Additionally, if their sales are 125% or more of their monthly goal of $90,000, then all employees will receive a message stating that they will get a day off. 

function Main() 

var real monthlySales; 

bonusMoney = getBonus(); 

dayoff = getdayOff(); 

getSales = monthySales(); 

function getSales(Real Ref monthlySales) 

return prompt("Enter the total sales for the month."); 

end function 

function getBonus(Real Ref monthlySales) 

If monthlySales >=100000 Then 

Println ?You get a bonus of $5,000!!!?; 

End If 

End function 

function GetDayoff(Real Ref monthlySales) 

if monthlySales >=112500 Then 

Println ? You get a bonus of $5,000!!!?; 

Println ?All employees get one day off!!!?; 

End If 

End function 

Main(); 

When I run this in the display window all I get is

...

Is this Javascript or something else?

It looks odd...

Link to comment
Share on other sites

  • 0

I didn't copy the code from anywhere. It was from my pseudocode from an algorithm of the homework assignment. I realized later I had mixed the javascript code and pseudocode together and of course it didn't work. I am struggling with the JS  code. I am not a programmer, but I'm trying to learn this stuff. I know I still have issues with the code I have and it is too late for the assignment anyway, but I do want to figure this out so I can move forward with this class.

 

Here is my revised code:

 

// Bonus program

 

function main()

//Declare local variables

var real monthlySales;

//Function calls

{

  monthlySales = getSales();

  bonusMoney = getBonus();

  dayOff = getdayOff();

}

//this module takes in the required user input

function getSales(monthlySales)

{

  return prompt("Enter the total sales for the month.");

}

//this module will determine if a bonus is awarded.  If

//sales are greater than or equal to 100000, then they

//get a 5000 bonus

function getBonus(Real Ref monthlySales)

{

  if monthlySales >=100000 then

      println ?You get a bonus of $5,000!!!?;

}

 

//this module will determine if all employees get a day

//off.  If sales are greater than or equal to 125% of $90000,

//then they get a day off.

 

function getDayoff(Real Ref monthlySales)

{

  if monthlySales >=112500 then

      println ? You get a bonus of $5,000!!!?;

      println ?All employees get one day off!!!?;

}

Link to comment
Share on other sites

This topic is now closed to further replies.