-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Criação e começo da implementação do projeto
- Loading branch information
0 parents
commit da8242c
Showing
6 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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])*")); | ||
} | ||
} | ||
} |