Purchase Appple Purchase Orange

Principles of Information Systems (MindTap Course List)
12th Edition
ISBN:9781285867168
Author:Ralph Stair, George Reynolds
Publisher:Ralph Stair, George Reynolds
Chapter8: Electronic And Mobile Commerce
Section: Chapter Questions
Problem 3SAT
icon
Related questions
Question

Instructions

This assignment uses the logic from the recent quiz and assignment.  You can see some of that code in there.
What is different?  The sequence of operations, spending and finding money, is totally controllable with buttons.
This makes the program very flexible.

Update the Code below with the following:

  1. Add 2 new event functions: buyTortilla() and addFoundMoney().
  2. Add 2 new buttons that trigger buyTortilla() and addFoundMoney().

STARTER CODE

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

 

 

<! 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
orange=20 // price of 1 orange
tortilla=30 // price of 1 tortilla
foundMoney=25 || pretend found $25
T| initialize the user-interface when this page loads:
document.getElementById ("balance").innerHTML = "$"+change;
// Step 2. define event functions for each button
function buyApple(){
change
document.getElementById ("balance").innerHTML
// price of 1 apple
apple;
= "$"+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>
Transcribed Image Text:<! 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 orange=20 // price of 1 orange tortilla=30 // price of 1 tortilla foundMoney=25 || pretend found $25 T| initialize the user-interface when this page loads: document.getElementById ("balance").innerHTML = "$"+change; // Step 2. define event functions for each button function buyApple(){ change document.getElementById ("balance").innerHTML // price of 1 apple apple; = "$"+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>
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Random Class and its operations
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
Principles of Information Systems (MindTap Course…
Principles of Information Systems (MindTap Course…
Computer Science
ISBN:
9781285867168
Author:
Ralph Stair, George Reynolds
Publisher:
Cengage Learning
MIS
MIS
Computer Science
ISBN:
9781337681919
Author:
BIDGOLI
Publisher:
Cengage
Fundamentals of Information Systems
Fundamentals of Information Systems
Computer Science
ISBN:
9781337097536
Author:
Ralph Stair, George Reynolds
Publisher:
Cengage Learning
Principles of Information Systems (MindTap Course…
Principles of Information Systems (MindTap Course…
Computer Science
ISBN:
9781305971776
Author:
Ralph Stair, George Reynolds
Publisher:
Cengage Learning
Fundamentals of Information Systems
Fundamentals of Information Systems
Computer Science
ISBN:
9781305082168
Author:
Ralph Stair, George Reynolds
Publisher:
Cengage Learning
Microsoft Windows 10 Comprehensive 2019
Microsoft Windows 10 Comprehensive 2019
Computer Science
ISBN:
9780357392607
Author:
FREUND
Publisher:
Cengage