Sunteți pe pagina 1din 5

1.

Escreva um algoritmo que receba um nmero inteiro N, verifique se este mpar ou


par e imprima mensagem.

2.Escreva um algoritmo que receba os coeficientes de uma equao do segundo grau,
determine e imprima suas razes reais, caso haja, ou uma mensagem, caso as razes
sejam complexas.

3. Escreva um algoritmo que receba trs nmeros e mostre o menor.
/*
* ALGORITMO QUE RECEBE UM NUMERO INTEIRO E VERIFICA SE E IMPAR OU PAR
* CRIADO POR HAMILTON DE TARSO SOUZA
*/

import java.util.Scanner;

public class exercicio1
{
public static void main (String args[])
{
Scanner sc =new Scanner(System.in);

int n;

System.out.print("Entre com um numero inteiro:");
n =sc.nextInt();

if(n %2 ==0)
{
System.out.print("O numero e par");
}
else
{
System.out.print("O numero e impar");
}
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
}
}

/*
* ALGORITMO QUE RESOLVE UM EQUAO DO SEGUNDO GRAU E RETORNA RAIZ REAL
* CRIADO POR HAMILTON DE TARSO SOUZA
*/

import java.util.Scanner;

public class exercicio2
{
public static void main (String args[])
{
Scanner sc =new Scanner(System.in);

double a,b,c;
double delta,x1,x2;

System.out.println("Entre com o valor de a");
a =sc.nextDouble();

while(a ==0)
{
System.out.println("O valor de A nao pode ser zero para uma equacao
do segundo grau");

System.out.println("Entre com o valor de a");
a =sc.nextDouble();
}

You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
System.out.println("Entre com o valor de b");
b =sc.nextDouble();

System.out.println("Entre com o valor de c");
c =sc.nextDouble();

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

x1 =0;
x2 =0;

if(delta >=0)
{
x1 =(-b +(Math.sqrt(delta))) / (2*a);

x2 =(-b - (Math.sqrt(delta))) / (2*a);

System.out.println("Valor de Delta e:" +delta);

System.out.println("Raiz real de x1 e:" +x1);

System.out.println("Raiz real de x2 e:" +x2);
}
else
{
System.out.print("Equacao nao pode ser resolvida com conjunto dos
numeros reais");
}
}
}

You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
/*
* ALGORITMO QUE RECEBE 3 NUMEROS E RETORNA O MENOR DELES
* CRIADO POR HAMILTON DE TARSO SOUZA
*/

import java.util.Scanner;

public class exercicio3
{
public static void main(String[] args)
{
Scanner sc =new Scanner(System.in);
int n1,n2,n3,menor;

System.out.print("Entre com o primeiro numero:");
n1 =sc.nextInt();

System.out.print("Entre com o segundo numero:");
n2 =sc.nextInt();

System.out.print("Entre com o terceiro numero:");
n3 =sc.nextInt();

if(n1 <n2 && n1 <n3)
{
menor =n1;
}
else if(n2 <n3)
{
menor =n2;
}
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
else
{
menor =n3;

}

System.out.print("O menor numero :" +menor);
}
}

You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)

S-ar putea să vă placă și