Question

JavaScript - I need help formulating executable code for the following problem. 7.15 The process of...

JavaScript - I need help formulating executable code for the following problem.

7.15 The process of finding the largest value (i.e., the maximum of a group of values) is used frequently in computer applications. For example, a script that determines the winner of a sales contest would input the number of units sold by each sales person. The salesperson who sells the most units wins the contest. Write a pseudocode ode algorithm and then a script that inputs a series of 10 single- digit numbers as characters, determines the largest of the numbers and outputs a message that dis- plays the largest number. Your script should use three variables as follows:

a) counter : A counter to count to 10 (i.e., to keep track of how many numbers have been input and to determine when all 10 numbers have been processed)

b) number : The current digit input to the script;

c) largest : The largest number found so far

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

Code:

----------------------------------------------------------------------------------------------------------------------------------------------------------

output:

it asks user to enter 10 numbers (it ask to enter one after the other by sumiting) .....in this exampe i entered numbers in range (0,9) as task to enter single digit.....so,here as per my values the largest one will be 9...(you can give your own values to find largest among them)....

------------------------------------------------------------------------------------------------------------------------------------------------------

code:

<html>
<head></head>
<body>
<script type="text/javascript">
var c=1; // counter
var num= new Array;   
num.length=9; //array with size 10 from index 0
var newnumber; // use to take input
var larg=0; // to check for larger one

while (c <= 10) {
newnumber=window.prompt("Enter Numbers 0-9 Number: "+c+".");
if(parseInt(newnumber)<10){
num[c]= parseInt(newnumber); //parsing the string input to int
if(num[c]>larg){ // checking for large condition
larg=num[c];
}}
else{
alert("enter single digit"); //to enter again
c--; // to decrement counter to enter again value at same index
}
c++; // incrementing counter
}
//displaying largest one among 10 numbers
document.write("<h1>Largest number is "+larg+"</h1>");
</script>
</body>
</html>

----------------------------------------------------------------------------------------------------------------------------------------------

Note: I already done this question in HomeworkLib,so i'm reflecting the same with some modifications as per question!

Add a comment
Know the answer?
Add Answer to:
JavaScript - I need help formulating executable code for the following problem. 7.15 The process of...
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
  • The process of finding the largest value is used frequently in computer applications. For example...

    The process of finding the largest value is used frequently in computer applications. For example, a program that determines the winner of a sales contest would input the number of units sold by each salesperson. The salesperson who sells the most units wins the contest. Write a Ruby application that allows a user to input a series of 10 integers and determines and prints the largest integer. Your program should use at least the following three variables: a) counter: A...

  • NEED HELP with HTML with Javascript embedding for form validation project below. I have my code...

    NEED HELP with HTML with Javascript embedding for form validation project below. I have my code below but I'm stuck with validation. If anyone can fix it, I'd really appreciate. ****************************************************************************** CODE: <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html> <head> <title>Nice</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script> var textFromTextArea; function getWords(){ var text =...

  • I need help with a C++ assignment: Write a program containing the following: 1. Variable Definitions...

    I need help with a C++ assignment: Write a program containing the following: 1. Variable Definitions only as (DieRoll, Guess, cnt1, cnt2) followed by this statement: srand((unsigned int)time (NULL)); which will give the random number generator a random starting point. Note: srand and rand require the TIME.H (or iomanip) cnt1 and cnt2 will be used in Chapter 5 drop box as counters for loops. Do NOT create additional variables. Points will be taken off for any additional variable creation. 2....

  • I need help finding what is wrong with this code, it is for a CS course...

    I need help finding what is wrong with this code, it is for a CS course I am taking which codes in C (I am using XCode on Mac to code). This is the assignment: "Write a program that performs character processing on 10 characters read in from a file, and writes the results to output files. The program should read from “input.dat”. The program should write the ASCII values of the characters to “output_ascii.dat”. The program should print statistics...

  • Use program control statements in the following exercises: Question 1 . Write pseudocode for the following:...

    Use program control statements in the following exercises: Question 1 . Write pseudocode for the following: • Input a time in seconds. • Convert this time to hours, minutes, and seconds and print the result as shown in the following example: 2 300 seconds converts to 0 hours, 38 minutes, 20 seconds. Question 2. The voting for a company chairperson is recorded by entering the numbers 1 to 5 at the keyboard, depending on which of the five candidates secured...

  • In java language here is my code so far! i only need help with the extra...

    In java language here is my code so far! i only need help with the extra credit part For this project, you will create a Rock, Paper, Scissors game. Write a GUI program that allows a user to play Rock, Paper, Scissors against the computer. If you’re not familiar with Rock, Paper, Scissors, check out the Wikipedia page: http://en.wikipedia.org/wiki/Rock-paper-scissors This is how the program works: The user clicks a button to make their move (rock, paper, or scissors). The program...

  • Could anyone help add to my python code? I now need to calculate the mean and...

    Could anyone help add to my python code? I now need to calculate the mean and median. In this programming assignment you are to extend the program you wrote for Number Stats to determine the median and mode of the numbers read from the file. You are to create a program called numstat2.py that reads a series of integer numbers from a file and determines and displays the following: The name of the file. The sum of the numbers. The...

  • This is a matlab HW that I need the code for, if someone could help me figure this out it would b...

    This is a matlab HW that I need the code for, if someone could help me figure this out it would be appreciated. The value of t can be estimated from the following equation: in your script file, estimate the value of π for any number of terms. You must ask the user for the desired number of terms and calculate the absolute error/difference between your calculation and the built-in MATLAB value ofpi. Display your results with the following message...

  • i need help making this program the skeleton of the code is below: //Include the following #include <iostream> #...

    i need help making this program the skeleton of the code is below: //Include the following #include <iostream> #include <string> #include <fstream> //you must include this library if you wish to do file i/o using namespace std; /********************************************************* //Following is the declaration of a order record **********************************************************/ class order_record { public: string cell_number; string item_number; double quantity; double price; int processing_plant; double tax_rate; double order_tax; double net_cost; double total_cost; }; //Prototypes for your functions: input, output, and process will go...

  • MATLAB help! I have some MATLAB Assignment to do, the proffesor requires all the small parts...

    MATLAB help! I have some MATLAB Assignment to do, the proffesor requires all the small parts in order to get full credit. Help me out, thank you f LAB SECTION NAME HW6P3 (30 points) following are infinite series representations of the function, un pra i a script file HW6P3 that determines the value of the function from the sum of the series for a given value of x. The program (1 pt) must prompt the user to enter a value...

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