8!DOCTYPE html 40 41 42

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
<!DOCTYPE html>
<html>
<body>
<script>
//
// Write a function that calculates the amount of money a person would earn over
// a period of years if his or her salary is one penny the first day, two pennies
// the second day, and continues to double each day. The program should ask the
// user for the number of years and call the function which will return the total
// money earned in dollars and cents, not pennies. Assume there are 365 days
// in a year.
//
function totalEarned (years) {
// Insert your code between here and the next comment block.
Do not alter
//
// any code in any other part of this file.
// Insert your code between here and the previous comment block.
// any code in any other part of this file.
Do not alter //
//
var years = parseInt(prompt('How many years will you work for pennies a day? '));
var totalDollarsEarned = totalEarned (years);
alert('Over a total of ' + years + ', you will have earned $' + totalDollarsEarned);
</script>
</body>
</html>
Transcribed Image Text:<!DOCTYPE html> <html> <body> <script> // // Write a function that calculates the amount of money a person would earn over // a period of years if his or her salary is one penny the first day, two pennies // the second day, and continues to double each day. The program should ask the // user for the number of years and call the function which will return the total // money earned in dollars and cents, not pennies. Assume there are 365 days // in a year. // function totalEarned (years) { // Insert your code between here and the next comment block. Do not alter // // any code in any other part of this file. // Insert your code between here and the previous comment block. // any code in any other part of this file. Do not alter // // var years = parseInt(prompt('How many years will you work for pennies a day? ')); var totalDollarsEarned = totalEarned (years); alert('Over a total of ' + years + ', you will have earned $' + totalDollarsEarned); </script> </body> </html>
8!DOCTYPE html
<html>
<body>
<script>
3
//
// The following program will prompt the user for a starting number and an
// ending number. Assume that these are whole numbers (no decimal points),
// assume the numbers are not negative and assume that the first number is
// not larger than the second number.
9.
10
//
// write a funcTion that returns the sum of the numbers from the starting
// number to the ending number. For example, if the starting number is 13
// and the ending number is 18 then the function will return the value of
// 13 + 14 + 15 + 16 + 17 + 18.
// number then simply return that number.
11
12
13
14
If the starting number is equal to the ending
15
16
//
17
18
19
function sum0fNumbers(startingNumber, endingNumber) {
20
21
//
22
// Insert your code between here and the next comment block.
Do not alter
//
23
// any code in any other part of this file.
24
//
25
26
27
28
// Insert your code between here and the previous comment block.
Do not alter //
29
// any code in any other part of this file.
//
30
31
32
33
var startingNumber = parseInt(prompt('What is the starting number? '));
var endingNumber = parseInt(prompt('What is the ending number? '));
var sumOfNumbersPassed = sum0fNumbers(startingNumber, endingNumber);
34
35
36
37
38
alert('The sum of the numbers from ' + startingNumber + ' to ' + endingNumber +
is ' + sum0fNumbersPassed);
39
</script>
</body>
40
41
42
</html>
Transcribed Image Text:8!DOCTYPE html <html> <body> <script> 3 // // The following program will prompt the user for a starting number and an // ending number. Assume that these are whole numbers (no decimal points), // assume the numbers are not negative and assume that the first number is // not larger than the second number. 9. 10 // // write a funcTion that returns the sum of the numbers from the starting // number to the ending number. For example, if the starting number is 13 // and the ending number is 18 then the function will return the value of // 13 + 14 + 15 + 16 + 17 + 18. // number then simply return that number. 11 12 13 14 If the starting number is equal to the ending 15 16 // 17 18 19 function sum0fNumbers(startingNumber, endingNumber) { 20 21 // 22 // Insert your code between here and the next comment block. Do not alter // 23 // any code in any other part of this file. 24 // 25 26 27 28 // Insert your code between here and the previous comment block. Do not alter // 29 // any code in any other part of this file. // 30 31 32 33 var startingNumber = parseInt(prompt('What is the starting number? ')); var endingNumber = parseInt(prompt('What is the ending number? ')); var sumOfNumbersPassed = sum0fNumbers(startingNumber, endingNumber); 34 35 36 37 38 alert('The sum of the numbers from ' + startingNumber + ' to ' + endingNumber + is ' + sum0fNumbersPassed); 39 </script> </body> 40 41 42 </html>
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
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