Purchase Appple Purchase Orange

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education