Created
July 24, 2014 14:27
-
-
Save RenatoRosaFranco/554a643b752b304768a5 to your computer and use it in GitHub Desktop.
Calculadora em Java - 24/07/2014
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
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package javaapplication1; | |
/** | |
* | |
* @author Laboratório | |
*/ | |
public class JavaApplication1 { | |
/** | |
* @param args the command line arguments | |
*/ | |
public static void main(String[] args) { | |
// TODO code application logic here | |
// Inicio | |
System.out.println("\n#=================================#"); | |
System.out.println("# INICIO #"); | |
System.out.println("#=================================#"); | |
System.out.println("Bem vindo a Calculadora RTH"); | |
System.out.println(" - Renato Franco"); | |
System.out.println(" - Matheus Costa"); | |
JavaApplication1 obj = new JavaApplication1(); | |
obj.Principal(); | |
} | |
public void Principal() | |
{ | |
// Variavvel | |
int decision; | |
System.out.println("\n#=================================#"); | |
System.out.println("# 1 - Adição #"); | |
System.out.println("# 2 - Subtração #"); | |
System.out.println("# 3 - Divisão #"); | |
System.out.println("# 4 - Multiplicação #"); | |
System.out.println("#=================================#"); | |
System.out.println("\nEscolha a Operação Selecionando o\nNumero Correspondente\n"); | |
decision = 4; | |
switch(decision) | |
{ | |
case 1: | |
System.out.println("Chamando Função [: Adição ]"); | |
JavaApplication1 objcall = new JavaApplication1(); | |
// Chama | |
objcall.Soma(20,30); | |
break; | |
// Caso 2 | |
case 2: | |
System.out.println("Chamando Função [: Subtração ]"); | |
JavaApplication1 objcallz = new JavaApplication1(); | |
// Chama | |
objcallz.Sub(20,30); | |
break; | |
// Caso 2 | |
case 3: | |
System.out.println("Chamando Função [: Divisão ]"); | |
JavaApplication1 objcalla = new JavaApplication1(); | |
objcalla.Div(10,5); | |
// Chama | |
break; | |
case 4: | |
System.out.println("Chamando Função [: Multiplicação ]"); | |
JavaApplication1 objcallb = new JavaApplication1(); | |
objcallb.Mult(10,5); | |
break; | |
// Defaul | |
default: | |
System.out.println("Parametro Errado, Tente Novamente "); | |
JavaApplication1 objcalls = new JavaApplication1(); | |
objcalls.Principal(); | |
break; | |
} | |
} | |
// Soma | |
private void Soma(int n1, int n2) | |
{ | |
int soma; | |
// Pega os numeros | |
soma = ( n1 + n2 ); | |
System.out.println("\n#=================================#"); | |
System.out.println("# Resultado da Soma é " + soma + " #"); | |
System.out.println("#=================================#"); | |
} | |
private void Sub(int n1, int n2) | |
{ | |
int sub; | |
// Pega os numeros | |
sub = ( n1 - n2 ); | |
System.out.println("\n#=================================#"); | |
System.out.println("# Resultado da Subtração é " + sub + " #"); | |
System.out.println("#=================================#"); | |
} | |
// Divisao | |
private void Div(int n1, int n2) | |
{ | |
int div; | |
// Pega os numeros | |
div = ( n1 / n2 ); | |
System.out.println("\n#=================================#"); | |
System.out.println("# Resultado da Divisao é " + div + " #"); | |
System.out.println("#=================================#"); | |
} | |
private void Mult(int n1, int n2) | |
{ | |
int mult; | |
// Pega os numeros | |
mult = ( n1 * n2 ); | |
System.out.println("\n#=================================#"); | |
System.out.println("# Resultado da Multiplicação é " + mult + " #"); | |
System.out.println("#=================================#"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment