Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Login

Register Now

Welcome to All Test Answers

Assignment 2 -Intro to programming javascript

MIT 153 – Assignment #2

A company is in the business of leasing construction
equipment. They have a number of sales people who need to find new deals to
sign. They are given a bonus at the end of each quarter based on the total
dollar amount of the lease deals they signed during the previous three months.

If they signed $175,000 worth of deals in the latest quarter
they will be given a bonus of $5,000. If they signed $100,000 or more but less
than $175,000 then they will get a bonus of $2,500 plus 1% of the amount they
signed.

Those who did not achieve $100,000 worth of signed
agreements are still eligible for a $1,000 bonus if they signed 10% more than they
did in the previous quarter.

Create an algorithm using a flow chart to determine the
salesperson’s bonus. It will start by asking for their name and the total of
the deals they signed this past quarter. It will also ask for the amount of
sales from the previous quarter if that information is necessary. It will end
by displaying a message such as:                              “John
earned a bonus or $3,700 by signing $120,000 of leases”

Create a JavaScript program that will implement this code. Be sure to include appropriate comments, including your name as the programmer.

Flow chart

<html>
<body>
<script type="text/javascript">
//Assignment#2

// Variable Declarations

var BR = "<br />";
var name; //employee First & Last Name
var deals; //Total Amount of Deal in the Last Quarter 
var salesLastQr; //Total Amount of Deals from the Previous Quarter

// input 

name= prompt("Enter Employee Name", "");
deals= prompt("Enter The Total of Deals in The Last Quarter", "");

// PROCESSING 

if (deals>=175000) {
document.write(name + " earned a bonus of $ 5000 by signing $" + deals + " of leases");
}
else if (deals>=100000){
document.write(name + " earned a bonus of $ "  + (2500+parseFloat(.01*deals)) + " by signing $" + deals + " of leases");
}
else {
      salesLastQr= prompt("Enter The Amount of Sales from The Previous Quarter", "");
      if (deals>1.1*salesLastQr){
      document.write(name + " earned a bonus of $ 1000 by signing $" + deals + " of leases");
      }
      else{
      document.write(name + ", Sorry You earned no bonus : ( ");
      }
      }

</script>
</body>
</html>



About

Leave a reply

Captcha Click on image to update the captcha .

error: Content is protected !!