0% found this document useful (0 votes)
9 views3 pages

Do While CONTAGEM

contagem do while java

Uploaded by

Victor Queiroz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Do While CONTAGEM

contagem do while java

Uploaded by

Victor Queiroz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

/*

* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to
change this license
*/

package com.mycompany.exercicioswhile;
import javax.swing.JOptionPane;
/**
*
* @author computador
*/
public class ExerciciosWhile {

public static void main(String[] args) {

int n ;
int par = 0 ;
int impar =0;
int acima = 0;
int media=0;
int s =0;
int conta =0;

do{

n = Integer.parseInt(JOptionPane.showInputDialog(null,"digite o n°"));
if(n!=0){
s += n;
conta ++;
if(n%2==0){
par ++;

}else{

impar++;
}

if(n > 100){

acima ++;

}
media = s/conta;
}

}while(n != 0);
JOptionPane.showMessageDialog(null, "<html>Resultado:<br><hr>"+" total de
valores: "+conta+"<br> total de pares : "+par
+"<br> total de impares: "+impar+"<br>n° acima de 100: "+acima+"<br>soma
total:"+s+" media: "+ media);

}
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to
change this license
*/

package com.mycompany.exercicioswhile;
import javax.swing.JOptionPane;
/**
*
* @author computador
*/
public class ExerciciosWhile {

public static void main(String[] args) {

int n ;
int par = 0 ;
int impar =0;
int acima = 0;
int media=0;
int s =0;
int conta =0;

do{

n = Integer.parseInt(JOptionPane.showInputDialog(null,"digite o n°"));
if(n!=0){
s += n;
conta ++;
if(n%2==0){
par ++;

}else{

impar++;
}

if(n > 100){

acima ++;

}
media = s/conta;
}

}while(n != 0);
JOptionPane.showMessageDialog(null, "<html>Resultado:<br><hr>"+" total de
valores: "+conta+"<br> total de pares : "+par
+"<br> total de impares: "+impar+"<br>n° acima de 100: "+acima+"<br>soma
total:"+s+" media: "+ media);

}
}

You might also like