Java Review questions

Source: Internet
Author: User

Exercises:

20 judges scored for a contestant, removed 1 highest points, removed 1 minimum points, and averaged

Ideas:

1. html

2. Add Event: Click on the next one when the jury + + text box empty The value of the text box to JS

var btn = document.getElementById ("btn");

Btn.setattribute ("Oncilk", "Next ()"); Define an array

var arr = [],

n=0;

function Next () {//Get score text box get score

var Fs=document.getelementbyid ("Fenshu");

Arr[n]=fs.value;

n=n+1; The number of judges has changed. Find the value of element modified element

document.getElementById ("SP1"). Innerhtml=n=n+1;

Fs.value= ""; Empty Fractional text box

if (n>2) {//Cycle comparison results in highest score lowest score

Getmaxmin ()

}

}

Funcution Getmaxmin () {

var max=arr[0],//Initialize max number minimum

Min=arr[0],

sum=0;

for (var n in arr) {

if (Max<arr[n]) {

Max=arr[n];

}

sum=+sum++arr[n[; Score

}

document.getElementById ("Max"). Innerhtml=max; Place a value in the label to find the element to modify

Document,getelementbyid ("Min"). Innerhtml=min;

Document.getelementbyid.inerhtml= (sum-+max-min)/(arr.length-2);

}

function Show (type) {

var max=arr[0],

Min=arr[0],

Avg=0,

sum=0;

for (var n in arr) {

if (Max<arr[n]) {

Max=arr[n];

}

Sum=+sum++arr[n]; Score

}

avg= (Sum-+max-+main)/(Arr.length-2)

Switch (type) {

Case "Max":

document.getElementById ("Max"). Innerhtml=max;

Break

Case "min":

document.getElementById ("Min"). Innerhtml=min;

Break

Case "AVG";

document.getElementById ("avg"). Innerhtml=avg;

Break

}

Java Review questions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.