Você está na página 1de 7

lista de exercícios

nome: Vinicius Silva Andrade Turma: 2B

import javax.swing.JOptionPane;
public class Atv3 {
public static void main ( String[] args){
String input = JOptionPane.showInputDialog( "digite sua idade",
"digite aqui" );

int nome = Integer.parseInt(input);

if ( nome < 2 ){
JOptionPane.showMessageDialog(null, "Você é Bebe");

}else if ( nome < 11 ){


JOptionPane.showMessageDialog(null, "Você é criança");

}else if (nome < 17){


JOptionPane.showMessageDialog(null, "Você é adolecente");

}else if (nome < 24){


JOptionPane.showMessageDialog(null, "Você é jovem");

}else if (nome < 59){


JOptionPane.showMessageDialog(null, "Você é Adulto");

}else if (nome < 99){


JOptionPane.showMessageDialog(null, "Você é idoso");

}else if (nome >= 100){


JOptionPane.showMessageDialog(null, "Você é ancião");

} else{}}}
import javax.swing.JOptionPane;
public class Atv4 {
public static void main ( String[] args){

String input = JOptionPane.showInputDialog( "digite a nota da


lista", "digite aqui" );
int nota1 = Integer.parseInt(input);

String input2 = JOptionPane.showInputDialog( "digite a nota do


seminário", "digite aqui" );
int nota2 = Integer.parseInt(input2);

String input3 = JOptionPane.showInputDialog( "digite a nota da


prova", "digite aqui" );
int nota3 = Integer.parseInt(input3);

float result = nota1 * 2 + nota2 * 3 + nota3 * 5 % 10;

if( result > 6){


JOptionPane.showMessageDialog(null, " aprovado ");

}else{
JOptionPane.showMessageDialog(null, " reprovado ");
}}}
import javax.swing.JOptionPane;

public class Atv5 {


public static void main(String[] args) {
String baseInput = JOptionPane.showInputDialog("Digite o número
base:");
double base = Double.parseDouble(baseInput);

String expoenteInput = JOptionPane.showInputDialog("Digite o


expoente:");
int expoente = Integer.parseInt(expoenteInput);

double resultado = calcularPotencia(base, expoente);

JOptionPane.showMessageDialog(null, "O resultado é: " +


resultado);
}

public static double calcularPotencia(double base, int expoente) {


double resultado = 1;

if (expoente >= 0) {
for (int i = 0; i < expoente; i++) {
resultado *= base;
}
} else {
for (int i = 0; i > expoente; i--) {
resultado /= base;
}
}

return resultado;
}
}
import java.util.*;

public class Atv6{


public static void main(String[] args) {
verificarParImpar();
}

public static void verificarParImpar() {


Scanner scanner = new Scanner(System.in);

System.out.print("Digite um número: ");


int numero = scanner.nextInt();

if (numero % 2 == 0) {
System.out.println("O número " + numero + " é par.");
} else {
System.out.println("O número " + numero + " é ímpar.");
}

}}
import javax.swing.JOptionPane;

public class Atv7 {


public static void main(String[] args) {
calcularMedia();
}

public static void calcularMedia() {


int[] numeros = new int[10];
int soma = 0;

for (int i = 0; i < 10; i++) {


String numInput = JOptionPane.showInputDialog("Digite um
número:");
int num = Integer.parseInt(numInput);
numeros[i] = num;
soma += num;
}

double media = (double) soma / 10;


String numerosMaiores = "";

for (int j = 0; j < 10; j++) {


if (numeros[j] > media) {
numerosMaiores += numeros[j] + " ";
}
}

JOptionPane.showMessageDialog(null, "Números maiores que a


média: " + numerosMaiores);
}}
import javax.swing.JOptionPane;

public class Atv8 {

public static void main(String[] agrs){

long velocidade =
Long.parseLong(JOptionPane.showInputDialog("digite a velocidade de
lançamento do projétio"));

short angulo =
Short.parseShort(JOptionPane.showInputDialog("digite o ângulo de
lançamento do projétio"));

long d = (long)
(((Math.pow(velocidade,2))*(Math.sin(Math.toDegrees(angulo)*2)))/10);

long h = (long) ((Math.pow(velocidade,


2))*(Math.pow(Math.sin(Math.toDegrees(angulo)*2),2))/20);

JOptionPane.showMessageDialog(null,"A distância máxima atingida


foi "+d+"\n altura máxima alcançada foi "+h);
}
}

import java.util.Random;

import javax.swing.JOptionPane;

public class Atv9 {


public static void main(String[] args) {

Random generate = new Random();

String senha2 = "";

for (int i = 0; i < 6; i++) {


char senha1 = ((char) (generate.nextInt(26) + 'A'));
senha2 += senha1 + " ";
}

JOptionPane.showMessageDialog(null, "senha gerada: " + senha2);


}}
import java.util.*;

public class Atv10 {


public static void main (String [] args){
Scanner scan= new Scanner (System.in);
double a, b, c, x1, x2;

System.out.println ("Digite o a: ");


a = scan.nextInt();

System.out.println ("Digite o b: ");


b = scan.nextInt();

System.out.println ("Digite o c: ");


c = scan.nextInt();

double delta= (b*b) - 4*a*c;

if (delta>0){
x1= (-b+ Math.sqrt(delta))/2*a;
x2= (-b- Math.sqrt(delta))/2*a;
System.out.println ("As raizes são: "+x1+(" ")+x2);
} else if (delta == 0 ){
x1= (-b+ Math.sqrt(delta))/2*a;
x2=x1;
System.out.println ("As raizes são: "+x1+(" ")+x2);
} else{
System.out.println ("sem raiz doido");
}

}}

Você também pode gostar