Question

Please please help with the code! Apperciate all the effort --create using html5, css3, and javas...

Please please help with the code! Apperciate all the effort

--create using html5, css3, and javascript.

--The interface permits the user to compute the number of primes in ranges of integer values.
--The interface should present the user with 4 pairs of "number" boxes in which 4 pairs of integer values can be entered. Each pair of values should be used by a thread to compute the number of prime numbers in that range, inclusive.
-- If any box is empty, then no thread should be created to compute the (empty) range.
--Provide a start button that the user can click when the above values have been entered.
--Finally, when the computation is complete, the number of primes in all ranges should be displayed on the page with a brief meaningful message.

--It is valid to assume that no range of numbers will include a number smaller than 3. All ranges are inclusive.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the output screenshot.

This is done using HTML,CSS and javascript only as requested.

*****************************************************************************************************************************************

Screenshot of the output:

Prime numbers Pair 1 Number 1 Number 1 Result: 127 131 137 139 149 Pair 2 Number 1 2 Number 1134 Result: 13 17 19 23 29 31 37

*****************************************************************************************************************************************

Code:

<!DOCTYPE html>
<html>
<style>
input[type=date],[type=text], select {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}

button {
width: 100%;
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
}

input[type=submit]:hover {
background-color: #45a049;
}

div {
border-radius: 5px;
background-color: #f2f2f2;
padding: 20px;
}
</style>
<body>

<center><h2>Prime numbers</h2></center>
<br>
<div>
<u><h3>Pair 1</h43></u><br><br>
<label for="number 1">Number 1</label>
<input type="number" id="pair_1_num_1">

<label for="number 2">Number 1</label>
<input type="number" id="pair_1_num_2">

<div>
<label for="number 1">Result : </label>
<span id="result1"></span>
</div>
</div>

<br>

<div>
<u><h3>Pair 2</h43></u><br><br>
<label for="number 1">Number 1</label>
<input type="number" id="pair_2_num_1">

<label for="number 2">Number 1</label>
<input type="number" id="pair_2_num_2">

<div>
<label for="number 2">Result : </label>
<span id="result2"></span>
</div>
</div>

<br>

<div>
<u><h3>Pair 3</h43></u><br><br>
<label for="number 1">Number 1</label>
<input type="number" id="pair_3_num_1">

<label for="number 2">Number 1</label>
<input type="number" id="pair_3_num_2">

<div>
<label for="number 3">Result : </label>
<span id="result3"></span>
</div>
</div>

<br>

<div>
<u><h3>Pair 4</h43></u><br><br>
<label for="number 1">Number 1</label>
<input type="number" id="pair_4_num_1">

<label for="number 2">Number 1</label>
<input type="number" id="pair_4_num_2">

<div>
<label for="number 4">Result : </label>
<span id="result4"></span>
</div>
</div>

<button id="calculate" onclick="calculatePrime()">Calculate</button>
<br>
</body>
<script type="text/javascript">
function calculatePrime(){
var pair_1_num_1 = document.getElementById("pair_1_num_1").value;
var pair_1_num_2 = document.getElementById("pair_1_num_2").value;
var pair_2_num_1 = document.getElementById("pair_2_num_1").value;
var pair_2_num_2 = document.getElementById("pair_2_num_2").value;
var pair_3_num_1 = document.getElementById("pair_3_num_1").value;
var pair_3_num_2 = document.getElementById("pair_3_num_2").value;
var pair_4_num_1 = document.getElementById("pair_4_num_1").value;
var pair_4_num_2 = document.getElementById("pair_4_num_2").value;

var result1 = document.getElementById("result1").innerHTML = "";
var result2 = document.getElementById("result2").innerHTML = "";
var result3 = document.getElementById("result3").innerHTML = "";
var result4 = document.getElementById("result4").innerHTML = "";


if(pair_1_num_1.length != 0 && pair_1_num_2.length!=0)
executeAsyncTask(function() {
findPrimesInRange(pair_1_num_1, pair_1_num_2,document.getElementById("result1"));
});
if(pair_2_num_1.length != 0 && pair_2_num_2.length!=0)
executeAsyncTask(function() {
findPrimesInRange(pair_2_num_1, pair_2_num_2,document.getElementById("result2"));
});
if(pair_3_num_1.length != 0 && pair_3_num_2.length!=0)
executeAsyncTask(function() {
findPrimesInRange(pair_3_num_1, pair_3_num_2,document.getElementById("result3"));
});
if(pair_4_num_1.length != 0 && pair_4_num_2.length!=0)
executeAsyncTask(function() {
findPrimesInRange(pair_4_num_1, pair_4_num_2,document.getElementById("result4"));
});
}

function findPrimesInRange(a,b,resultSpan){
var i = 0;
var flag = 0;
var j = 0;
for (i = a; i <= b; i++) {
if (i == 1) {
continue;
}
flag = 1;
for (j = 2; j <= i / 2; ++j) {
if (i % j == 0) {
flag = 0;
break;
}
}
if (flag == 1) {
//alert("PrimesInRange " + i);
resultSpan.innerHTML = resultSpan.innerHTML + " " + i;
}
}
}

function executeAsyncTask(func) {
setTimeout(func, 0);
}

</script>
</html>

*****************************************************************************************************************************************

Add a comment
Know the answer?
Add Answer to:
Please please help with the code! Apperciate all the effort --create using html5, css3, and javas...
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
  • PLs someone pls help me by editing my code to calculate the 4 pair of range to calculate the prim...

    PLs someone pls help me by editing my code to calculate the 4 pair of range to calculate the prime numbers by using web workers(You will have to use 4 workers). (I already have the code to manipulate the prime numbers but I need your help with web worker part)(code is below) Can someone pls help with the code of computing prime number for four pair of an integer values by using web worker concept ! Appreciate all the effort!...

  • Finding number pairs that add to n without using arrays or hashing

    ProblemGiven a number n between 1 and 12 (inclusive), your job is to find all the pairs of numbers that produce n when summed. For instance, given the number 5, two possible pairs of numbers are1, 4 and 2, 3. Each number in the pair must be unique, meaning that 3, 3 is not a valid pair to sum to 6.You will be writing a method to accomplish this goal.sumOfPairs()Your method will take as a parameter the integer n to...

  • The Sieve of Eratosthenes is a simple, ancient algorithm for finding all prime numbers up to...

    The Sieve of Eratosthenes is a simple, ancient algorithm for finding all prime numbers up to any given limit. It does so by iteratively marking as composite lie., not prime) the multiples of each prime, starting with the multiples of 2 The sieve of Eratosthenes can be expressed in pseudocode, as follows: Input: an integer n Let A be an array of 8oo1ean values, indexed by integers 2 to n, initially all set to true. for t - 2, 3,...

  • Create an HTML5 page that contains a form to collect the following data. The text in...

    Create an HTML5 page that contains a form to collect the following data. The text in bold indicates the id value that should be assigned to each html control: Product (drop down list) product – iPad, iPhone 6S, Galaxy 5S, Moto X, and so on Quantity (number) quantity Unit price (number) unit_price Discount (%)(number) discount_rate Date (date)   order_date First Name (text box)   first_name Last Name (text box)   last_name Payment type (drop down list)   payment_type – Visa, Master, Discover, Amex, and...

  • I need help in C++ assignment. please add statements and i am Xcode complier user. Requested...

    I need help in C++ assignment. please add statements and i am Xcode complier user. Requested files: CountDecades.cpp (Download) Maximum upload file size: 96 KiB Write a C++ program named CountDecades.cpp. In this program you will have two integer arrays. One named inputArray of size 20 containing the values: 83, 2, 23, 11, 97, 23, 41, 67, 16, 25, 1 , 4, 75, 92, 52, 6, 44, 81, 8, 64 in the order specified, and an empty integer array of...

  • Write the code in C with all the right output please. Problem: In this assignment you...

    Write the code in C with all the right output please. Problem: In this assignment you will analyze a data set of 10,000 randomly generated integers. From this data set you will display a count of the prime numbers that are greater than the average (double) of the entire data set. The user will input only a single integer value to serve as the seed for the random number generator. The use of a common seed will result in output...

  • Add JavaScript code in the “find_primeV2.js” to allow users to enter a number, and then based...

    Add JavaScript code in the “find_primeV2.js” to allow users to enter a number, and then based on the number of user enters, to find out how many prime numbers there are up to and including the user inputted number and then display them on the web page. The following are the detailed steps to complete this assignment: Step 1. [30 points] In “find_primeV2.js”, complete isPrime() function by (1) Adding one parameter in function header. That parameter is used to accept...

  • Use the IO module for all inputs and outputs. Sevens are considered lucky numbers. Your task...

    Use the IO module for all inputs and outputs. Sevens are considered lucky numbers. Your task is to count the number of sevens that appear within a range of integer numbers. Your solution should make use of looping constructs. Ask the user for the following information, in this order: The lower end of the range The upper end of the range Compute and then output the number of sevens that appear in the sequence from lower end to upper end...

  • PLEASE HELP!!! C PROGRAMMING CODE!!! Please solve these functions using the prototypes provided. At the end...

    PLEASE HELP!!! C PROGRAMMING CODE!!! Please solve these functions using the prototypes provided. At the end please include a main function that tests the functions that will go into a separate driver file. Prototypes int R_get_int (void); int R_pow void R Jarvis int start); void R_fill_array(int arrayll, int len); void R_prt_array (int arrayl, int len) void R-copy-back (int from[], int to [], int len); int R_count_num (int num, int arrayll, int len) (int base, int ex) 3. Build and run...

  • c++ please help You are going to create a PowerBall Lottery game with functions. First, you...

    c++ please help You are going to create a PowerBall Lottery game with functions. First, you are going to generate 5 UNIQUE numbers between 1 and 69. Then you are going to generate the powerball number, which is a number between 1 and 26. Next you are going to ask the user for 5 numbers. Users should only be allowed to enter numbers in the range 1-69 for regular numbers, 1-26 for powerball pick. You will compare each of the...

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