File

Propaganda
DELEGAÇÃO REGIONAL DO ALENTEJO
CENTRO DE FORMAÇÃO PROFISSIONAL DE ÉVORA
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ficha.pkg2_0789_1;
import java.util.Scanner;
/**
*
* @author IEFP
*/
public class Ficha2_0789_1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
// Variáveis
int subtracao;
int num1;
int num2;
Scanner in = new Scanner(System.in);
System.out.print("Insira o valor de A: ");
num1 = Integer.parseInt(in.next());
System.out.print("Insira o valor de B: ");
num2 = Integer.parseInt(in.next());
subtracao = num1-num2;
if (subtracao>0) {
System.out.println("O número "+num1+" é maior que o número "+num2);
}else if (subtracao<0) {
System.out.println("O número "+num2+" é maior que o número "+num1);
}
else {
System.out.println("O número "+num1+" e igual ao número "+num2);
}
}
}
DELEGAÇÃO REGIONAL DO ALENTEJO
CENTRO DE FORMAÇÃO PROFISSIONAL DE ÉVORA
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ficha.pkg2_0789_2;
import java.util.Scanner;
/**
*
* @author IEFP
*/
public class Ficha2_0789_2 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner in = new Scanner(System.in);
System.out.print("Insira um número inteiro: ");
int num1 = (int) Double.parseDouble(in.next());
System.out.print("Insira o fator N: ");
int fact1 = Integer.parseInt(in.next());
int res1 = 1;
int ix1;
for (ix1 = 1; ix1 <= fact1; ix1++) {
res1 = res1 * num1;
}
System.out.println("resultado do cálculo: " + res1);
}
}
DELEGAÇÃO REGIONAL DO ALENTEJO
CENTRO DE FORMAÇÃO PROFISSIONAL DE ÉVORA
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ficha.pkg2_0789_3;
import java.util.Scanner;
/**
*
* @author IEFP
*/
public class Ficha2_0789_3 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int res1 = 0;
int ix1;
Scanner in = new Scanner(System.in);
System.out.print("Insira um número qualquer: ");
double num1 = Double.parseDouble(in.next());
if (num1 < 4) {
res1 = 0;
System.out.println("resultado: " + res1);
} else if (num1 == 4) {
res1 = 1;
System.out.println("resultado: " + res1);
} else if (num1 > 4 && num1 <= 10) {
System.out.println("resultado: ");
for (ix1 = (int) (num1 - 1); ix1 >= num1 - 4; ix1 = ix1 - 1) {
res1 = res1 + ix1;
if (ix1== (num1 - 1)){
System.out.print(ix1);
} else{
System.out.print("+" + ix1);
}
}
System.out.println("=" + res1);
} else {
res1 = 1;
System.out.println("resultado: ");
for (ix1 = (int) (num1 - 1); ix1 >= num1 - 5; ix1 = ix1 - 2) {
res1 = res1 * ix1;
if (ix1== (num1 - 1)){
System.out.print(ix1);
DELEGAÇÃO REGIONAL DO ALENTEJO
CENTRO DE FORMAÇÃO PROFISSIONAL DE ÉVORA
} else{
System.out.print("*" + ix1);
}
}
System.out.println("=" + res1);
}
}
}
DELEGAÇÃO REGIONAL DO ALENTEJO
CENTRO DE FORMAÇÃO PROFISSIONAL DE ÉVORA
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ficha.pkg2_0789_4;
import java.util.Scanner;
/**
*
* @author IEFP
*/
public class Ficha2_0789_4 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int opcao1;
double USD=1.3;
double CHF=1.22;
double RUB=42.19;
double valor_eur;
double valor_usd;
double valor_chf;
double valor_rub;
Scanner in = new Scanner(System.in);
System.out.println("Escolha um das opções:");
System.out.println("1-> Conversão de Euros(EUR) em Dólares(USD), Francos Suícos(CHF) e
Rublos(RUB)");
System.out.println("2-> Conversão de Dólares(USD) em Euros(EUR), Francos Suícos(CHF) e
Rublos(RUB)");
opcao1 = Integer.parseInt(in.next());
if (opcao1==1){
System.out.println("Insira um valor(EUR): ");
valor_eur = Double.parseDouble(in.next());
valor_usd = valor_eur * USD;
valor_chf = valor_eur * CHF;
valor_rub = valor_eur * RUB;
}else {
System.out.println("Insira um valor(USD): ");
valor_usd = Double.parseDouble(in.next());
valor_eur = valor_usd / USD;
valor_chf = valor_eur * CHF;
valor_rub = valor_eur * RUB;
}
if (opcao1==1) {
DELEGAÇÃO REGIONAL DO ALENTEJO
CENTRO DE FORMAÇÃO PROFISSIONAL DE ÉVORA
System.out.println("Valor inserido em EUR: "+valor_eur);
System.out.println("Valor convertido em USD: "+valor_usd);
}else {
System.out.println("Valor inserido em USD: "+valor_usd);
System.out.println("Valor convertido em EUR: "+valor_eur);
}
System.out.println("Valor convertido em CHF: "+valor_chf);
System.out.println("Valor convertido em RUB: "+valor_rub);
}
}
Download