Question

IN HTML Programming 1. Write a script that inputs integers (one at a time) and passes...

IN HTML Programming

1. Write a script that inputs integers (one at a time) and passes them one at a time to function isEven, which uses the modulus operator to determine whether an integer is even. The function should take an integer argument and return true if the integer is even and false otherwise. Use sentinel-controlled looping and a prompt dialog.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
<html>
<head>
    <title>Check Even Numbers</title>
</head>
<body>
<script>
    function isEven(n) {
        return n % 2 === 0;
    }

    while (true) {
        var n = Number(prompt("Enter a number(-1 to exit)", "-1"));
        if (n === -1) {
            break;
        }
        if (isEven(n)) {
            alert(n + " is even.");
        } else {
            alert(n + " is odd.");
        }
    }
</script>
</body>
</html>
Add a comment
Know the answer?
Add Answer to:
IN HTML Programming 1. Write a script that inputs integers (one at a time) and passes...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a script that inputs integers (one at a time) and passes them one at a...

    Write a script that inputs integers (one at a time) and passes them one at a time to function isEven. which uses the modulus operator to determine whether an integer is even. The function should take an integer argument and return true if the integer is even and false otherwise. Use sentinel-controlled looping and a prompt dialog. notepad++

  • Write a function called isEven() that uses the remainder (modulus) operator (%) to determine when an...

    Write a function called isEven() that uses the remainder (modulus) operator (%) to determine when an integer is even. The function should take an integer argument called myNumber passed from within the for loop and return true if the integer is even and false otherwise. Your program should determine what numbers are even and odd from 1 to 20 using the isEven() function. Your counter variable in the for loop should be called num.

  • Java Programming Write a method named isEven that accepts an integer argument. The method should return...

    Java Programming Write a method named isEven that accepts an integer argument. The method should return true if the argument is even, or false if not. The program’s main method should use a loop to generate a random integer. The number of random integers is provided by a user, who must enter a number greater than 10. The loop should then invoke the isEven method to determine whether each integer is even or odd, display the random number and the...

  • Question is two parts In R(Programming language). Define and write a function which takes one number...

    Question is two parts In R(Programming language). Define and write a function which takes one number as input and detects whether the number is even. Return TRUE if it is even, and FALSE otherwise. You need to first detect if the input is an integer; if not, return NA. Note 1: TRUE and FALSE are logical values, not strings! Note 2: No need to get user input from the console. Test your function using your_function_name(1), your_function_name(2), and your_function_name(1.5). Hint: What...

  • In Haskell programming language (1) Write a "averageThree" function to return the average of three integers....

    In Haskell programming language (1) Write a "averageThree" function to return the average of three integers. averageThree :: Integer -> Integer -> Integer -> Float (2) Write a "howManyAboveAverage" function which returns how many of three integer inputs are above its average value. (utilize the averageThree function.) howManyAboveAverage :: Integer -> Integer -> Integer -> Integer (3) Write a "howManyWithinThreshold" function that returns how many of the first three arguments are within the threshold (the fourth argument) of the average...

  • This is in Java. Write the application, TheSentinel  to read a set of integers. Stop reading input...

    This is in Java. Write the application, TheSentinel  to read a set of integers. Stop reading input when a non-integer is read. Use this exact prompt: System.out.print("Enter an integer or Q to quit: "); Note: you will actually quit on any non-integer. Do the following things: Find and print the sum of all the even numbers Find and print the smallest of the inputs Determine if the number 7 is in the input. If 7 is in the inputs, print "7...

  • Write a bash script that accepts one command line argument 'a' which is an integer between 1 and 50 inclusive. I...

    Write a bash script that accepts one command line argument 'a' which is an integer between 1 and 50 inclusive. It should output a list of integers from 'a' and ending with '1' according to the following iteration rule. ( fx = x/2 if x is even; fx=3x+1 if x is odd )

  • 7.11 Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track...

    7.11 Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several tankfuls of gasoline by recording the number of miles driven and the number of gallons used for each tankful. Develop a script that will take as input the miles driven and gallons used (both as integers) for each tankful. The script should calculate and output HTML5 text that displays the number of miles per gallon obtained for each tankful and the combined...

  • Is Prime Number In this program, you will be using C++ programming constructs, such as functions....

    Is Prime Number In this program, you will be using C++ programming constructs, such as functions. main.cpp Write a program that asks the user to enter a positive integer, and outputs a message indicating whether the integer is a prime number. If the user enters a negative integer, output an error message. isPrime Create a function called isPrime that contains one integer parameter, and returns a boolean result. If the integer input is a prime number, then this function returns...

  • Python Programming Task 2: Leap Years   Part A - Is this a leap year? Write a...

    Python Programming Task 2: Leap Years   Part A - Is this a leap year? Write a function is leap year(year) that calculates whether a given (CE) year is a leap year. The function must: • take one argument: a positive integer representing a year (assumed to be CE) • return True if that year was a leap year; return False if not NOTE: all years that are divisible by four are leap years, unless they are also divisible by 100,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT