<!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 enters an expense of 0 at which time the function // returns the total for the monthly expenses. The program should display the amount // that the user is over or under budget. // function collectMonthlyExpenses() { ///////////////////////////////////////////////////////////////////////////////// // 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 monthlyBudget = parseFloat(prompt('What is your monthly budget? ')); var monthlyExpenses = collectMonthlyExpenses(); if (monthlyExpenses > monthlyBudget) { var overOrUnder = monthlyExpenses-monthlyBudget; alert('You are over budget by $' + overOrUnder); } else if (monthlyExpenses < monthlyBudget) { var overOrUnder = monthlyBudget-monthlyExpenses; alert('You are under budget by $' + overOrUnder); } else { alert('You are right on budget!'); } </script> </body> </html>
<!DOCTYPE html>
<html>
<body>
<!-- replace the text below with your
name!-->
<!-- -->
<!-- -->
<title> TYPE YOUR
NAME HERE</title><!--Here your have to write your
name-->
<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 enters an expense of 0 at which
time the function
// returns the total for the monthly expenses. The program should
display the amount
// that the user is over or under budget.
//
var total_expenses=0; //This variable will store the total
expenses entered during the loop
var expense=0;//This variable is used to take input of the expense
during the loop
function collectMonthlyExpenses() {
/////////////////////////////////////////////////////////////////////////////////
expense=parseFloat(prompt('Enter your expense'));//This will
take the input
total_expenses=total_expenses+expense;//This will add the entered
input to the total expense
if(expense!=0)//This line checks weather loop is continued or not
if user entered 0 it terminates the loops otherwise it will
continue the loop
{
collectMonthlyExpenses();
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
return total_expenses;//This will return the total_expenses to
store this variable in monthlyExpenses variable
/////////////////////////////////////////////////////////////////////////////////
}
var monthlyBudget = parseFloat(prompt('What is your monthly
budget? '));
var monthlyExpenses = collectMonthlyExpenses();
alert("Your Total Monthly Expenses is $"+monthlyExpenses);//This
line will display the your total monthly expenses
if (monthlyExpenses > monthlyBudget) {
var overOrUnder =
monthlyExpenses-monthlyBudget;
alert('You are over
budget by $' + overOrUnder);
} else if (monthlyExpenses < monthlyBudget) {
var overOrUnder =
monthlyBudget-monthlyExpenses;
alert('You are under
budget by $' + overOrUnder);
} else {
alert('You are right on
budget!');
}
</script>
</body>
</html>
<!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 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...
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...
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?...
<!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...
in the following java script code follow the instructions provided <!DOCTYPE html> <html> <head> <!-- JavaScript 6th Edition Chapter 5 Hands-on Project 5-2 Author: Date: Filename: index.htm --> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Hands-on Project 5-2</title> <link rel="stylesheet" href="styles.css" /> <script src="modernizr.custom.05819.js"></script> </head> <body> <header> <h1> Hands-on Project 5-2 </h1> </header> <article> <h2>Change of address form</h2> <form> <fieldset id="contactinfo"> <label for="addrinput"> Street Address </label> <input type="text" id="addrinput" name="Address" /> <label for="cityinput"> City </label> <input type="text" id="cityinput" name="City"...
Javascript + HTML, no JQuery please. So, Im trying to figure out how to send an alert if the value of my selection is "0". I will be using this for a validation form assignement. So if the user leaves the selection on the default "0" value I can prompt the user to pick a valid option which would be 1+. Not sure how to access this value. Example code below: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Form Validation</title>...
HTML Canvas: I have given my small html + js mix code below. By this program- I can just draw line, but after drawing any image I want to save the "image " on my desktop. I understand, I have to make a "button" to SAVE it and later if I want to load the picture, then I have to make a button on the webpage to "LOAD". But I am unable to understand the function I should write for...
Rewrite the code below using JavaScript only <!DOCTYPE html> <html> <head> <style> .hidden {display:none;} </style> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("p").click(function(){ $(this).hide(); }); }); </script> </head> <body> <p>paragraph1</p> <p>paragraph2</p> <p>paragraph3</p> </body> </html>