FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaGB/lista_4_java/questao_2.java at main · githubdaestela/JavaGB · GitHub
githubdaestela
/
JavaGB
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
7
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaGB
/
lista_4_java
/
questao_2.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
41 lines (35 loc) · 1012 Bytes
Breadcrumbs
JavaGB
/
lista_4_java
/
questao_2.java
Copy path
File metadata and controls
41 lines (35 loc) · 1012 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*Lista 4 Lista de Array: 2. Faça um programa que receba 6 números inteiros e mostre:
• Os números pares digitados;
• A soma dos números pares digitados;
• Os números ímpares digitados;
• A quantidade de números ímpares digitados.*/
package
lista_4_java
;
import
java
.
util
.*;
public
class
questao_2
{
public
static
void
main
(
String
args
[])
{
Scanner
input
=
new
Scanner
(
System
.
in
);
int
[]
number
=
new
int
[
5
];
int
acmPar
=
0
,
somaPar
=
0
,
acmImpar
=
0
,
somaImpar
=
0
;
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
System
.
out
.
println
(
"Entre com um número: "
);
number
[
i
]=
input
.
nextInt
();
if
(
i
%
2
==
0
)
{
acmPar
++;
somaPar
=
somaPar
+
i
;
}
else
{
acmImpar
++;
somaImpar
=
somaImpar
+
i
;
}
}
System
.
out
.
println
(
"Foram digitados "
+
acmPar
+
" números pares."
);
System
.
out
.
println
(
"A soma de número pares é "
+
somaPar
+
"."
);
System
.
out
.
println
(
"Foram digitados "
+
acmImpar
+
" números ímpares."
);
System
.
out
.
println
(
"A soma de número pares é "
+
somaImpar
+
"."
);
}
}
Back
|
FazBrowse Home
|
New Git URL