Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit db210ec

Browse files
Completed Assignments
1 parent 8785e66 commit db210ec

File tree

5 files changed

+78
-0
lines changed

5 files changed

+78
-0
lines changed

ch04/.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ch04/DemoMath.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
public class DemoMath
2+
{
3+
public static void main(String[] args)
4+
{
5+
int a = 2;
6+
int b = 3;
7+
8+
int abs = Math.abs(a);
9+
int max = Math.max(a, b);
10+
double pow = Math.pow(a,b);
11+
double pi = Math.PI;
12+
13+
System.out.println("Before: "+ a + " After: " + abs);
14+
System.out.println("Before: "+ a + ", " + b + " After: " + max);
15+
System.out.println("Before: "+ a + ", " + b + " After: " + pow);
16+
System.out.println(pi);
17+
18+
}
19+
}

ch04/Exercise3.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
public class Exercise3
2+
{
3+
public static void main(String[] args)
4+
{
5+
printAmerican( "Wednesday", 18, "April" , 2018);
6+
printEuropean( "Wednesday",18,"April", 2018);
7+
}
8+
public static void printAmerican( String day, int date, String month, int year )
9+
{
10+
System.out.println("American format: " + day +", " + month +" "+ date +", "+ year);
11+
}
12+
public static void printEuropean( String day,int date, String month, int year)
13+
{
14+
System.out.println("European format: " + day +" " + day +" "+ month +" "+ year);
15+
16+
}
17+
}

ch04/MathUtil.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
public class MathUtil
2+
{
3+
4+
}

ch04/SimpleMethods.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
public class SimpleMethods
2+
{
3+
public static void main(String[] args)
4+
{
5+
printCount( 5 );
6+
7+
int count = 9;
8+
printCount(count);
9+
10+
int someNumber = 3;
11+
printCount(someNumber);
12+
13+
printSum( 4, 6);
14+
printSum(7, 2);
15+
16+
printBoolean( true);
17+
printBoolean(false);
18+
}
19+
public static void printCount(int count)
20+
{
21+
System.out.println("The count is: " + count);
22+
}
23+
public static void printSum(int x, int y)
24+
{
25+
int z = x + y;
26+
System.out.println(x + " + " + y + " = " + z);
27+
}
28+
public static void printBoolean(boolean isStudent)
29+
{
30+
System.out.println("I am a student: " + isStudent);
31+
}
32+
}

0 commit comments

Comments
 (0)