Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
secondWeekLab
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
cosmina.dunca
secondWeekLab
Commits
36121ccc
Commit
36121ccc
authored
Feb 14, 2022
by
cosmina.dunca
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Withoutex10
parent
9e9435a7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
124 additions
and
12 deletions
+124
-12
App.java
src/App.java
+124
-12
No files found.
src/App.java
View file @
36121ccc
...
...
@@ -2,29 +2,48 @@ public class App {
/* These are the exercises for the second week of java
Today is 14 February 2022
Cosmina Dunca */
public
static
void
main
(
String
[]
args
)
throws
Exception
{
System
.
out
.
println
(
"Hello, World!"
);
public
static
void
countDays
(){
int
daysPerWeek
=
7
;
// Ex 1.1
int
numberOfWeeks
=
6
;
// Ex 1.2
int
totalDays
=
daysPerWeek
*
numberOfWeeks
;
// Ex 1.3
System
.
out
.
println
(
totalDays
);
boolean
onHoliday
=
false
;
// Ex 1.4
}
public
static
void
circumference
(){
double
approxPI
=
3.14
;
// Ex 1.5
double
circumference
=
2
*
3
*
approxPI
;
double
circumf
=
2
*
3
*
approxPI
;
System
.
out
.
println
(
circumf
);
}
public
static
String
inigoSpeech
(
int
numFingers
){
String
greetingString
=
"Hello"
;
// Ex 1.7
String
introductionString
=
"My name is Inigo Montoya"
;
// Ex 1.8
String
reminderString
=
"You killed my father"
;
// Ex 1.9
String
threatString
=
"Prepare to die hahaha!"
;
// Ex 1.10
// System.out.println(greetingString + ", " + introductionString + ", " + reminderString + ", " + threatString); // Ex 1.11
// Exercise 4
int
fingersOnRightHand
=
5
;
if
(
fingersOnRightHand
==
6
)
{
System
.
out
.
println
(
greetingString
+
", "
+
introductionString
+
", "
+
reminderString
+
", "
+
threatString
);
// Ex 1.11
if
(
numFingers
==
6
)
{
return
greetingString
+
", "
+
introductionString
+
", "
+
reminderString
+
", "
+
threatString
;
// Ex 1.11
}
else
{
System
.
out
.
println
(
"I am searching for the man who killed my father."
);
return
"I am searching for the man who killed my father."
;
}
}
public
static
boolean
isItALeapYear
(
int
year
){
if
(
year
%
4
==
0
){
return
true
;
}
else
{
return
false
;
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
System
.
out
.
println
(
"Hello, World!"
);
countDays
();
circumference
();
boolean
onHoliday
=
false
;
// Ex 1.4
// System.out.println(greetingString + ", " + introductionString + ", " + reminderString + ", " + threatString); // Ex 1.11
// Exercise 4 is in the method
System
.
out
.
println
(
inigoSpeech
(
5
));
// Exercise 5
int
month
=
2
;
switch
(
month
){
...
...
@@ -111,5 +130,98 @@ public class App {
System
.
out
.
println
(
"Not a valid month"
);
}
}
// Exercise 7
int
j
=
1
;
while
(
j
<
14
){
switch
(
j
){
case
1
:
System
.
out
.
println
(
"January"
);
break
;
case
2
:
System
.
out
.
println
(
"February"
);
break
;
case
3
:
System
.
out
.
println
(
"March"
);
break
;
case
4
:
System
.
out
.
println
(
"April"
);
break
;
case
5
:
System
.
out
.
println
(
"May"
);
break
;
case
6
:
System
.
out
.
println
(
"June"
);
break
;
case
7
:
System
.
out
.
println
(
"July"
);
break
;
case
8
:
System
.
out
.
println
(
"August"
);
break
;
case
9
:
System
.
out
.
println
(
"September"
);
break
;
case
10
:
System
.
out
.
println
(
"October"
);
break
;
case
11
:
System
.
out
.
println
(
"November"
);
break
;
case
12
:
System
.
out
.
println
(
"Decemmber"
);
break
;
default
:
System
.
out
.
println
(
"Not a valid month"
);
}
j
++;
}
j
=
1
;
do
{
switch
(
j
){
case
1
:
System
.
out
.
println
(
"January"
);
break
;
case
2
:
System
.
out
.
println
(
"February"
);
break
;
case
3
:
System
.
out
.
println
(
"March"
);
break
;
case
4
:
System
.
out
.
println
(
"April"
);
break
;
case
5
:
System
.
out
.
println
(
"May"
);
break
;
case
6
:
System
.
out
.
println
(
"June"
);
break
;
case
7
:
System
.
out
.
println
(
"July"
);
break
;
case
8
:
System
.
out
.
println
(
"August"
);
break
;
case
9
:
System
.
out
.
println
(
"September"
);
break
;
case
10
:
System
.
out
.
println
(
"October"
);
break
;
case
11
:
System
.
out
.
println
(
"November"
);
break
;
case
12
:
System
.
out
.
println
(
"Decemmber"
);
break
;
default
:
System
.
out
.
println
(
"Not a valid month"
);
}
j
++;
}
while
(
j
<
14
);
System
.
out
.
println
(
isItALeapYear
(
2011
));
}
}
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