<!DOCTYPE html><html><head><style>p {font-family: arial; font-size: 20px;} </style></head><body> <button onclick='buyApple()'>Purchase Appple</button><button onclick='buyOrange()'>Purchase Orange</button> <!-- This marks space for a paragraph that we can update during the program --><p id="balance"></p> <script>// javascript code begin// Step 1. initialize variables:change=100 // starting balanceapple=10 // price of 1 appleorange=20 // price of 1 orangetortilla=30 // price of 1 tortillafoundMoney=25 // pretend found $25// initialize the user-interface when this page loads:document.getElementById("balance").innerHTML = "$"+change;// Step 2. define event functions for each buttonfunction buyApple(){change -= apple;document.getElementById("balance").innerHTML = "$"+change;}function buyOrange(){change -= orange;document.getElementById("balance").innerHTML = "$"+change;}// Make 2 more functions here, to match the 2 new buttons: // javascript code end</script></body></html>   Bug report: the previous algorithm allows people to buy things when they don't have enough money. Correct that bug: Perform some maintenance on your Button's program. Don't allow purchases when the change is less than the purchase. Provide some feedback when that happens. How: Using conditionals, prevent people from buying things when they don't have enough money. For each button function, add some type of notification in your if-statments when that happens  such as You could give them a popup alert:alert("Denied: Insufficient balance"); Or write a message:document.write("Denied: Insufficient balance"); Or update a spot on the page (best method): document.getElementById("message").innerHTML= "Denied: Insufficient balance");

COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
1st Edition
ISBN:9780357392676
Author:FREUND, Steven
Publisher:FREUND, Steven
Chapter11: User Interfaces, Visual Basic For Applications (vba), And Collaboration Features
Section: Chapter Questions
Problem 13AYK
icon
Related questions
Question

<!DOCTYPE html>
<html><head><style>p {font-family: arial; font-size: 20px;} </style></head>
<body>

<button onclick='buyApple()'>Purchase Appple</button>
<button onclick='buyOrange()'>Purchase Orange</button>

<!-- This marks space for a paragraph that we can update during the program -->
<p id="balance"></p>

<script>
// javascript code begin
// Step 1. initialize variables:
change=100 // starting balance
apple=10 // price of 1 apple
orange=20 // price of 1 orange
tortilla=30 // price of 1 tortilla
foundMoney=25 // pretend found $25
// initialize the user-interface when this page loads:
document.getElementById("balance").innerHTML = "$"+change;
// Step 2. define event functions for each button
function buyApple(){
change -= apple;
document.getElementById("balance").innerHTML = "$"+change;
}
function buyOrange(){
change -= orange;
document.getElementById("balance").innerHTML = "$"+change;
}
// Make 2 more functions here, to match the 2 new buttons:

// javascript code end
</script>
</body>
</html>

 

Bug report: the previous algorithm allows people to buy things when they don't have enough money.

Correct that bug: Perform some maintenance on your Button's program.

  1. Don't allow purchases when the change is less than the purchase.
  2. Provide some feedback when that happens.

How:

  • Using conditionals, prevent people from buying things when they don't have enough money.
  • For each button function, add some type of notification in your if-statments when that happens  such as
    • You could give them a popup alert:alert("Denied: Insufficient balance");
    • Or write a message:document.write("Denied: Insufficient balance");
    • Or update a spot on the page (best method): document.getElementById("message").innerHTML= "Denied: Insufficient balance");
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Form and its Elements
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning