Note that there are some explanatory texts on larger screens.

plurals
  1. POError in my bonus calculator
    primarykey
    data
    text
    <p>Here is my code so far:</p> <pre><code># This program will determine the appropriate bonus to be given to both the store # and the employess. # Lab 3-4 # The main function def main(): monthlySales = getSales() # Call to get sales salesIncrease = getIncrease() # Call to get sales increase storeAmount = storeBonus(monthlySales) # Call to get the store bonus empAmount = empBonus(monthlySales) # Call to get the employee bonus printBonus (storeAmount, empAmount) # Call to print amounts # This function gets the monthly sales def getSales(): monthlySales = input('Enter the monthly sales $') monthlySales = float(monthlySales) return monthlySales # This function gets the percent of increase in sales def getIncrease(): salesIncrease = input('Enter percent of sales increase. For example, 4% should be entered as 4: ') salesIncrease = float(salesIncrease) salesIncrease = salesIncrease / 100 return salesIncrease # This function determines storeAmount bonus def storeBonus(monthlySales): if monthlySales &gt;=110000: storeAmount = 6000 elif monthlySales &gt;=100000: storeAmount = 5000 elif monthlySales &gt;=90000: storeAmount = 4000 elif monthlySales &gt;=80000: storeAmount = 3000 else: storeAmount = 0 return storeAmount # This function determines empAmount bonus def empBonus(salesIncrease): if salesIncrease &gt;= .05: empAmount = 75 elif salesIncrease &gt;= .04: empAmount = 50 elif salesIncrease &gt;= .03: empAmount = 40 else: empAmount = 0 return empAmount # This function prints the bonus information def printBonus(storeAmount, empAmount): print('The store bonus is $', storeAmount) print('The employee bonus is $', empAmount) if storeAmount == 6000 and empAmount == 75: print('Congrats! You have reached the highest bonus amounts possible!') # Calls main main() </code></pre> <p>Now in order to test this code I was give these following scenarios:</p> <blockquote> <p>1) monthlySales = 120500 salesIncrease = 5</p> <p>2) monthlySales = 93400 salesIncrease = 5</p> <p>3) monthlySales = 75000 salesIncrease = 1.5</p> <p>4) monthlySales = 82000 salesIncrease = 3.6</p> <p>5) monthlySales = 125000 salesIncrease = 4.5</p> </blockquote> <p>Now all is well up until 3-5. The "employee bonus amount" is not supposed to be $75, however that is what comes out. Any ideas on how to fix this problem? Anyone see any errors in my code that I failed to see?</p> <p>*Edit: What the code is supposed to output for each input value is as follows;</p> <p>1) $ 6000 $ 75</p> <p>2) $ 4000 $ 75</p> <p>3) $ 0 $ 0</p> <p>4) $ 3000 $ 40</p> <p>5) $ 6000 $ 50</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload