Professional Documents
Culture Documents
Calcule e escreva a soma das idades do homem mais velho com a mulher mais nova, e o
produto das idades do homem mais novo com a mulher mais velha.
import java.util.Scanner;
public class JavaApplication5 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int home1 = sc.nextInt();
int home2 = sc.nextInt();
int home3 = sc.nextInt();
int women1 = sc.nextInt();
int women2 = sc.nextInt();
int women3 = sc.nextInt();
int velho = 0;
int velha = 0;
int nova = 0;
int novo = 0;
int produto;
int soma;
if(home1>home2 && home1>home3){
velho=home1;
}
if(home2>1 && home2>home3){
velho=home2;
}
if (home3>home1 && home3>home2){
velho=home3;
}
if(women1>women2 && women1>women3){
velha=women1;
}
if(women2>1 && women2>women3){
velha=women2;
}
if(women3>women1 && women3>women2){
velha=women3;
}
if(women1<women2 && women1<women3){
nova=women1;
}
if(women2<women3 && women2<women1){
nova=women2;
}
if(women3<women2 && women3<women1){
nova=women3;
}
if(home1<home2 && home1<home3){
novo=home1;
}
if(home2<home1 && home2<home3){
novo=home2;
}
if(home3<home2 && home3<home1){
novo=home3;
}
produto = (novo*velha);
soma = nova+velho;
System.out.println("Produto: "+produto);
System.out.println("Soma: "+soma);
}
}
import java.util.Scanner;
public class JavaApplication5 {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
int i = 1;
while(i%2!=0){
int s =sc.nextInt();
if(s%2==0){
i=2;
}
}
System.out.println("Você digitou um número par");
}
}
5. Leia uma quantidade indeterminada duplas de valores inteiros X e Y. Escreva para
cada X e Y uma mensagem que indique se estes valores foram digitados em ordem
crescente ou decrescente. A leitura deve ser encerrada ao ser fornecido valores iguais
para X e Y.
import java.util.Scanner;
public class JavaApplication5 {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
int s =1;
while(s==1){
int x = sc.nextInt();
int y = sc.nextInt();
if(x!=y){
if(x>y){
System.out.println(x+" "+y+" Decrescente");
}else{
System.out.println(x+" "+y+" Crescente");
}
}else{
s = 2;
}
System.out.println("Fim");
}
}
}