• 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
https://www.neowin.net/forum/topic/1185699-java-script-homework-help/
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Hello,

  On 04/11/2013 at 02:40, kevinv said:

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...

  • 0
  • 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!!!?;

}

This topic is now closed to further replies.
  • Popular Now

  • Posts

    • You don't even know me and you're already swearing that you have been a Linux user for "longer than me" 😅. And how would you know that, by the way? And yes, I can speak my mind and say whatever the hell I want, even being a Linux user. Linux is great and all, but it isn't for everybody yet, especially if you're into MMO gaming and/or use specific professional software. And no, not everything works perfectly out of the box on Linux, some stuff doesn't work at all, and for the majority of users out there, that's a no-go. And don't you dare say that they don't want to learn, because that's true, they don't want to, because they are normal users, not tech enthusiasts. Open your eyes, 99.99% of people out there simply don't care about any of this.
    • But you don't know that. But I reported you to Neowin for encouraging illegal activation of Windows 10 LTSC by promoting grey market keys. Have a good weekend!!
    • Because the point of people doing all of this is to avoid Windows 11, genius. Many people don't want to upgrade and want to stay on 10 for the longest possible, because they don't like 11 for their particular reasons. That's what this whole debate is all about.
    • Gatekeepers? I’m a lifelong Linux user, longer than you! In fact I still use Windows 11, MacOS and Opensuse tumbleweed along with AnduinOS. You’re gatekeeping Windows over Linux!!! There is plenty of Linux distros for beginners!!! You’re no Linux user if you promote against it!!!
    • Windows 10 is the reason why we are so conscious about privacy now by Usama Jawad About a year ago, Microsoft debuted Recall in Windows 11, a feature that would record and remember everything that you do on your PC, allowing you to ask more contextual questions about your various activities and workflows from a dedicated assistant. Although the Redmond firm offered various privacy controls for Recall and even made it opt-in rather than mandatory, the launch was a disaster and the company had to recall Recall. All of this happened because people were not happy that Microsoft would record everything that they do on their PC and then share that information with an AI model, despite the company's assurances that all of this would happen locally and no data would be sent to Redmond's servers. Couple that with some lackluster security features and it was just a disaster waiting to happen. Although things have improved quite a bit since then, thanks to extensive testing in Insider Channels, some third-parties are still giving users controls that will allow them to block Recall for the vendor's software. I personally believe that this is a good thing, and we definitely should have more scrutiny around software that captures our activities (even with our consent). But as we approach Windows 10's 10th birthday and eventual end of support date, I can't help but realize that the main reason behind Windows customers being very privacy conscious nowadays is the beloved Windows 10 operating system itself. Windows 10 and the telemetry fiasco To truly understand what I mean, we have to go back a decade, to the launch of Windows 10 in 2015. Although the operating system has an ardent fanbase now, things weren't always this way. In fact, Windows 10 had a fairly rocky launch, and one of the reasons behind this was dreaded word telemetry. Anyone who has spent some time in the field of software development and productionizing solutions knows that telemetry typically the anonymized collection of data from various signals to monitor the health of software and diagnose a problem in case of any issues. Telemetry is very useful, for example, in cases where your Microsoft Word application may unexpectedly crash. Microsoft would monitor the telemetry logs from this crash, diagnose the problem, and ideally deliver a fix so that it doesn't happen on your or anyone else's device again. Now, telemetry collection is a regular process, all major software vendors have it at some level. However, when Microsoft decided to mention it in their privacy statement for Windows 10's Technical Preview (this is what Windows Insider Previews were called at that time) in 2014, there was massive uproar. Things spiraled to the point that people began to allege that Microsoft is spying on literally everything that you do through Windows 10. The backlash was so significant that by April 2015, a few months prior to the launch of Windows 10, Microsoft was scrambling to add new privacy controls in the operating system in response and the ability to delete content that Cortana (R.I.P) remembered about you. Heck, we even had software pirates and torrent-sharing groups banning Windows 10 over privacy concerns. Even Russian law firms began applying pressure on Moscow to investigate Microsoft over Windows 10's alleged spying. By 2017, Microsoft was under scrutiny from Switzerland, France, and other European authorities because of these claims. During this tumultuous period, the Redmond tech firm was constantly putting out statements to convince people that Windows 10 does not spy on you, all while building a dedicated privacy dashboard for the operating system and fixing actual Windows 10 privacy bugs. It was clear that Windows 10's launch hadn't been as smooth as the company probably would have wanted. Turning the privacy corner Things finally started to go in Microsoft's favor in April 2017, roughly two whole years after the launch of Windows 10. This was primarily because of the firm's increased transparency regarding data collection, enhanced privacy controls, and useful privacy reminders when installing new versions of Windows 10. By August 2017, Microsoft put out a statement saying that it is seeing "positive reception" from customers regarding privacy, indicating that it had finally turned a corner on the specific topic. This did not mean that Microsoft had been completely absolved by the public and regulators. It was still the target of regular regulator scrutiny, despite releasing new privacy controls frequently and constantly assuring customers that their data is not being sent to Microsoft without their consent. But it was clear that the worst was now behind. Where we stand now I would argue that the entire privacy and telemetry fiasco surrounding Windows 10 was blown out of proportion. I will emphasize again: telemetry collection is a regular process in software development and productionization, and it's something that every big firm does. However, a target was put on Microsoft's back just because it was a hot topic to spread fear, uncertainty, and doubt (FUD). As a Windows 10 veteran who has been around since the earliest days of the operating system's Technical Previews, I'm glad that we still managed to extract something positive out of this experience. Microsoft became very conscious about privacy (until Windows 11 Recall, that is), while we as customers began to understand that our data matters to us. Just because Windows 10 was not spying on us didn't mean that no one else is either. Media outlets like Neowin also became conscious of the topic, which is the main reason why we were able to avoid the disastrous initial launch of Windows 11 Recall. Despite how all of this started, all the FUD, I'm at least glad about where we ended. Although Windows 10 is adored by Microsoft customers even now, things weren't always like this. And as we celebrate the 10th birthday of the OS and its imminent device, it's important to be mindful of the fact that this is the operating system that made us so conscious about software privacy, and that's a good thing. This story is a part of our "10 Years of Windows 10" collection, in celebration of the operating system's tenth anniversary, falling on July 29, 2025. Over the next few days and weeks, you'll be able to find more content on this topic in our dedicated section available here.
  • Recent Achievements

    • Dedicated
      CarlosABC earned a badge
      Dedicated
    • One Month Later
      solidox earned a badge
      One Month Later
    • Week One Done
      Stephen Leibowitz earned a badge
      Week One Done
    • Week One Done
      Homayoun Hotak earned a badge
      Week One Done
    • Dedicated
      Profit earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      642
    2. 2
      ATLien_0
      240
    3. 3
      Xenon
      172
    4. 4
      neufuse
      155
    5. 5
      +FloatingFatMan
      122
  • Tell a friend

    Love Neowin? Tell a friend!