Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
main
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ProjetoIntegrador2018
M
minicurso
poo
main
Commits
14cb0bb6
Commit
14cb0bb6
authored
Aug 27, 2018
by
Victor Guerra Veloso
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Arquivos iniciais do workshop
parents
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
0 deletions
+55
-0
Calculadora.java
src/Calculadora.java
+44
-0
Operacao.java
src/Operacao.java
+3
-0
OperacaoLog.java
src/OperacaoLog.java
+8
-0
No files found.
src/Calculadora.java
0 → 100644
View file @
14cb0bb6
import
java.util.Scanner
;
public
class
Calculadora
{
private
Operacao
[]
operacao
;
public
Calculadora
()
{
operacao
=
new
Operacao
[
7
];
operacao
[
0
]
=
new
OperacaoSoma
();
operacao
[
1
]
=
new
OperacaoSub
();
operacao
[
2
]
=
new
OperacaoMult
();
operacao
[
3
]
=
new
OperacaoDiv
();
operacao
[
4
]
=
new
OperacaoPot
();
operacao
[
5
]
=
new
OperacaoRaiz
();
operacao
[
6
]
=
new
OperacaoLog
();
}
public
Operacao
[]
getOperacao
()
{
return
operacao
;
}
public
static
void
main
(
String
[]
args
)
{
Scanner
sc
=
new
Scanner
(
System
.
in
);
Calculadora
calc
=
new
Calculadora
();
int
entrada
=
0
;
double
x
=
0
;
double
y
=
0
;
System
.
out
.
println
(
"Olá usuário!"
);
System
.
out
.
println
(
"Bem vindo a calculadora do minicurso!"
);
while
(
true
)
{
System
.
out
.
println
(
"Escolha uma operação ou digite 0 para sair:"
);
System
.
out
.
println
(
"1- Soma; 2- Subtração; 3- Multiplicação; 4- Divisão; 5- Potẽncia; 6- Raiz, 7- Logarítmo"
);
entrada
=
sc
.
nextInt
();
if
(
entrada
==
0
)
{
break
;
}
System
.
out
.
print
(
"Digite o valor de x:"
);
x
=
sc
.
nextDouble
();
System
.
out
.
print
(
"Digite o valor de y:"
);
y
=
sc
.
nextDouble
();
System
.
out
.
println
(
"Resposta: "
+
calc
.
getOperacao
()[
entrada
-
1
].
opera
(
x
,
y
));
}
}
}
\ No newline at end of file
src/Operacao.java
0 → 100644
View file @
14cb0bb6
public
interface
Operacao
{
public
double
opera
(
double
x
,
double
y
);
}
src/OperacaoLog.java
0 → 100644
View file @
14cb0bb6
import
java.lang.Math
;
public
class
OperacaoLog
implements
Operacao
{
@Override
public
double
opera
(
double
x
,
double
y
)
{
return
Math
.
log
(
x
)
/
Math
.
log
(
y
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment