<!DOCTYPE html> <html> <body> <!-- replace the text below with your name!--> <!-- --> <!-- --> <title> TYPE YOUR NAME HERE</title> <script> // // Write a program that prompts the user to enter a number within the range of // 1 through 10 and calls a function to display the roman numeral version of // that number. If the number is outside the range of 1 through 10, the program // should display an error message. // // The following table shows the Roman numerals for the numbers 1 through 10: // 1 = I 4 = IV 7 = VII 10 = X // 2 = II 5 = V 8 = VIII // 3 = III 6 = VI 9 = IX // function romanNumeralVersion(decimalNumber) { ///////////////////////////////////////////////////////////////////////////////// // 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. Do not alter // // any code in any other part of this file. // ///////////////////////////////////////////////////////////////////////////////// } var decimalNumber = parseInt(prompt('Enter a number from 1 through 10')); alert(decimalNumber + ' as a Roman numeral is ' + romanNumeralVersion(decimalNumber)); </script> </body> </html>
The code with the required modification is below followed by IDE screenshot and testcase runs on the browser :
<!DOCTYPE html>
<html>
<body>
<!-- replace the text below with your name!-->
<!-- -->
<!-- -->
<title> Jane Martin </title>
<script>
//
// Write a program that prompts the user to enter a
number within the range of
// 1 through 10 and calls a function to display the
roman numeral version of
// that number. If the number is outside the range of
1 through 10, the program
// should display an error message.
//
// The following table shows the Roman numerals for
the numbers 1 through 10:
// 1 = I 4 = IV 7 = VII 10 = X
// 2 = II 5 = V 8 = VIII
// 3 = III 6 = VI 9 = IX
//
function romanNumeralVersion(decimalNumber) {
/////////////////////////////////////////////////////////////////////////////////
// Insert your code between here and the next comment
block. Do not alter //
// any code in any other part of this file. //
/////////////////////////////////////////////////////////////////////////////////
switch (decimalNumber){
case 1:
return
'I';
case 2:
return
'II';
case 3:
return
'III';
case 4:
return
'IV';
case 5:
return
'V';
case 6:
return
'VI';
case 7:
return
'VII';
case 8:
return
'VIII';
case 9:
return
'IX';
case 10:
return
'X';
default:
alert("Not a
valid input, please input any number from 1 through 10
only");
}
/////////////////////////////////////////////////////////////////////////////////
// Insert your code between here and the previous
comment block. Do not alter //
// any code in any other part of this file. //
/////////////////////////////////////////////////////////////////////////////////
}
var decimalNumber = parseInt(prompt('Enter a number from 1 through 10'));
alert(decimalNumber + ' as a Roman numeral is ' + romanNumeralVersion(decimalNumber));
</script>
</body>
</html>
IDE screenshot:
Browser screenshots:
When the page is loaded:
When the input is 9 and we click OK:
When the input is not within the range [1,10], an error message is printed in the alert box:
<!DOCTYPE html> <html> <body> <!-- replace the text below with your name!--> <!-- --> <!-- -->...
<!DOCTYPE html> <html> <body> <!-- replace the text below with your name!--> <!-- --> <!-- --> <title> TYPE YOUR NAME HERE</title> <script> // // Write a program that asks the user to enter the amount that he or she has // budgeted for a month. Call a function that uses a loop that prompts the user // to enter each of his or her expenses for the month and keep a running total. // The loop finishes when the user...
I need Notebook++ coding! Thanks so much I will upvote! <!DOCTYPE html> <html> <body> <!-- replace the text below with your name!--> <!-- --> <!-- --> <title> Jason Kidwell</title> <script> // // Scientists measure an object’s mass in kilograms and its weight in newtons. // If you know the amount of mass of an object in kilograms, you can calculate // its weight in newtons with the following formula: // // weight=mass×9.8 // // Write a...
<!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...
How can I connect the html forms to php --> mysql database <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <h2> <center> Average: </h2> <h3> <center> Rate the following: </h2> <h3> <center> Rating Criteria: <br> Developing (0-5), Competent (6-10), Accomplished (10-15); </h3> <center> Judge Name: <input type="text" id="judge"> <br> <br> <center> 1. Articulate requirements and design of the project: <input type="text" id="num1"> <br> <br> 2. Plan the solution and implement the project: <input type="text" id="num2"> <br> <br> 3....
<!DOCTYPE HTML>
<html lang="en">
<title>JavaScript Array Lab</title>
<script src="script.js"></script>
<body>
<p>To test your function,
call divideArray()
from the JavaScript console in the browser.</p>
</body>
</html>
Don't edit your code on the above code and do not copy from
others', plz!
// Put your solution here in script.js
Write the function divideArray() in script.js that has a single numbers parameter containing an array of integers. The function should divide numbers into two arrays, evenNums for...
<!-- DOCTYPE declaration --> <!DOCTYPE html> <!-- HTML boilerplate code --> <html lang="en"> <!-- head tag --> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Personal Webpage</title> </head> <!-- body tag --> <body> <style> .sidenav { height: 100%; width: 160px; position: fixed; z-index: 1; top: 0; left: 0; ...
Javascript to edit a HTML file. Where to begin? <!doctype html> <html> <head> <meta charset="utf-8"> <title>TODO: Change The Title</title> </head> <body> <h1></h1> <p>First paragraph.</p> <p class="intro">Second <span>paragraph</span>.</p> <button id="start">Start</button> <main> </main> <!-- Test 6: DOM Programming You MAY consult the notes for week 7, but you MAY NOT discuss this test or your code with any other students. All work must be your own. Instructions: 1. Put all solution code in a file named solution.js. When you upload your solution to...
<!-- DOCTYPE declaration --> <!DOCTYPE html> <!-- HTML boilerplate code --> <html lang="en"> <!-- head tag --> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Social</title> </head> <!-- body tag --> <body> <style> .sidenav { height: 100%; width: 160px; position: fixed; z-index: 1; top: 0; left: 0; background-color:...
I'm having trouble to link the .js file to the html so changes for the html to be made in the .js file <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>:JavaScript, HTML and jQuery</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> <!-- this is so I don't have to give you a separate CSS file --> <style> .hidden {display: none;} .menu { width: 100px;} </style> </head> <body> <div class="container"> <h1>Assignment 2: JavaScript, HTML and jQuery</h1> <p>To complete this...
Please help me with this code for javascript. <!DOCTYPE html> <html> <head> <title>Strings and Arrays</title> <script> function wrangleArray() { var string1 = prompt("Enter: This class is going to fast");//Must be entered by the user var string1 = "";//Is this right? I want that string to change later by a series of prompt questions document.getElementById("div1").innerHTML = "<p>" + sentence + "</p>"; var words = sentence.split(" ");//I need to convert my string to an Array is this the way to do it?...