Skip to content

Commit

Permalink
Criação e começo da implementação do projeto
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackStarSt committed Aug 24, 2022
0 parents commit da8242c
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path=""/>
<classpathentry kind="output" path=""/>
</classpath>
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Java-S1</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Binary file added ConversorDeMoedas/ConverteMoedas.class
Binary file not shown.
29 changes: 29 additions & 0 deletions ConversorDeMoedas/ConverteMoedas.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package ConversorDeMoedas;

import javax.swing.JOptionPane;

public class ConverteMoedas {
public void ReaisParaDolares (double valor) {
double dolar = valor / 5.12;
dolar = (double) Math.round(dolar * 100d) / 100;
JOptionPane.showMessageDialog(null, valor + " reais(R$) equivale a: " + dolar + " doláres(US$)");
}

public void ReaisParaEuros (double valor) {
double euros = valor / 5.09;
euros = (double) Math.round(euros * 100d) / 100;
JOptionPane.showMessageDialog(null, valor + " reais(R$) equivale a: " + euros + " euros(€)");
}

public void DolaresParaReais (double valor) {
double dolar = valor * 5.12;
dolar = (double) Math.round(dolar * 100d) / 100;
JOptionPane.showMessageDialog(null, valor + " dólares(US$) equivale a: " + dolar + " reais(R$)");
}

public void EurosParaReais (double valor) {
double euros = valor * 5.09;
euros = (double) Math.round(euros * 100d) / 100;
JOptionPane.showMessageDialog(null, valor + " euros(€) equivale a: " + euros + " reais(R$)");
}
}
Binary file added ConversorDeMoedas/index.class
Binary file not shown.
50 changes: 50 additions & 0 deletions ConversorDeMoedas/index.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package ConversorDeMoedas;
import javax.swing.JOptionPane;

public class index {
public static void main(String[] args) {
ConverteMoedas converter = new ConverteMoedas();

String[] tipoDeConversor = {"Conversor de Moedas", "Conversor de Temperatura"};
String pergunta = (String)JOptionPane.showInputDialog(null, "Escolha um tipo de conversor",
null, JOptionPane.QUESTION_MESSAGE, null, tipoDeConversor, tipoDeConversor[0]);
if(pergunta == tipoDeConversor[0]) {
String[] tipoDeMoeda = {"Reais em Dólar", "Reais em Euro", "Dólar em Reais", "Euro em Reais"};
String escolheMoedas = (String)JOptionPane.showInputDialog(null, "Escolha um tipo de conversor",
null, JOptionPane.QUESTION_MESSAGE, null, tipoDeMoeda, tipoDeMoeda[0]);
String input = null;
double valor;

do {
if(escolheMoedas == tipoDeMoeda[0]) {
input = JOptionPane.showInputDialog("Digite o valor em Reais(R$)");
if(input.matches("^[0-9]+$")) {
valor = Double.parseDouble(input);
converter.ReaisParaDolares(valor);
}
} else if (escolheMoedas == tipoDeMoeda[1]) {
input = JOptionPane.showInputDialog("Digite o valor em Reais(R$)");
if(input.matches("^[0-9]+$")) {
valor = Double.parseDouble(input);
converter.ReaisParaDolares(valor);
}
} else if (escolheMoedas == tipoDeMoeda[2]) {
input = JOptionPane.showInputDialog("Digite o valor em Dólares(US$)");
if(input.matches("^[0-9]+$")) {
valor = Double.parseDouble(input);
converter.ReaisParaDolares(valor);
}
}
else if (escolheMoedas == tipoDeMoeda[3]) {
input = JOptionPane.showInputDialog("Digite o valor em Euros(US$)");
if(input.matches("(?:\\.|[0-9])*")) {
valor = Double.parseDouble(input);
converter.ReaisParaDolares(valor);
} else {
JOptionPane.showMessageDialog(null, "Digite apenas números com ponto(.)");
}
}
} while(!input.matches("(?:\\.|,|[0-9])*"));
}
}
}

0 comments on commit da8242c

Please sign in to comment.