Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
- <html>
- <head>
- <title> Oving 7 </title>
- </head>
- <body>
- <h3> Gjennomsnitt, største og minste verdi </h3>
- <%
- String[] talls = request.getParameterValues("tall[]");
- int[] tall;
- int sum=0, storste=-9999999, minste=99999999;
- double snitt = 0;
- tall = new int[100];
- for(int i=0; i < 10; i=i+1)
- {
- tall[i] = Integer.parseInt(talls[i]);
- }//end for
- //-----------------------------------------------
- for(int i= 0; i < 10; i=i+1)
- {
- if (tall[i] > storste)
- {
- storste = tall[i];
- }
- else if( tall[i] < minste)
- {
- minste = tall[i];
- }//end if
- }//end for
- for(int i=0 ; i < 10; i=i+1)
- {
- sum = sum + tall[i];
- }//end for
- snitt = sum / 10;
- //-----------------------------------------------
- out.println("minste verdi er " + minste + ", største verdi er " + storste + " og gjennomsnittet av alle tallene er " + snitt);
- %>
- </body>
- </html>
Add Comment
Please, Sign In to add comment