Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class G3E3
- {
- public static void main(String[] args)
- {
- Scanner sc = new Scanner(System.in);
- double x, y, media, max = -Double.MAX_VALUE, min = Double.MAX_VALUE, sum=0;
- int c=0;
- System.out.print("Insira o seu conjunto de números: ");
- x = sc.nextInt();
- c++;
- do
- {
- System.out.print("Insira o seu conjunto de números: ");
- y = sc.nextInt();
- if(x==y)
- break;
- c++;
- if(y>max)
- max=y;
- if(y<min)
- min=y;
- sum+=y;
- }while(true);
- media = sum/c;
- System.out.printf("O valor máximo é %f, o valor mínimo é %f, a média é %f e foram inseridos %d números.", max, min, media, c);
- sc.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement