GoConqr has a new look! Let us know what you think.

Notes

Java vetor 21

juan rossini Portuguese 1 page

Content of the notes (1)

Page 1

import java.util.Scanner;

class ExericioVetor21 {

static void ler(float[]temp)

{

Scanner s;

int i;

s= new Scanner (System.in);

for(i=0;i< temp.length; i++){

System.out.print("Digite uma temperatura:");

temp[i] = s.nextFloat();

}

}

static float menor(float[]temp){

int i;

float min;

min=temp[0];

for (i=1;i <temp.length; i++){

if (temp[i]<min)

min=temp[i];

return min;

}

}

static float maior(float[]temp){

int i;

float max;

max=temp[0];

for (i=1;i <temp.length; i++){

if (temp[i]>max)

max=temp[i];

return min;

}

}

static float média(float[]temp)

{

int i;

float soma;

soma = 0.0f;

for (i=0;i < temp.length ; i++)

soma+= temp[i];

return soma/temp.length;

}

static int númeroDeDias(float[]temp,float med){

int i,num;

num = 0;

for (i=0 ; i < temp.length ; i++ )

if (temp[i] < med)

num++;

}

public static void main(String[]args){

float[]temperatura;

float res;

temperatura = new float[121];

ler(temperatura);

res= menor(temperatura);

System.out.println("Menor:"+ res);

res = maior (temperatura);

System.out.println("Maior"+res);

res = média (temperatura);

System.out.println("Média"+média);

num = númeroDeDias(temperatura,res);

System.out.println("Numero de dias com temperatura meor que a media:"+ num);

}

}

Information

Description
Note on Java vetor 21, created by juan rossini on 21/08/2018.
Created by
juan rossini
Views
0
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?