Skip to content

Commit 9f4fed4

Browse files
committed
Create method exercise
1 parent 4a7a41b commit 9f4fed4

10 files changed

Lines changed: 247 additions & 0 deletions

ch04/BigMethodSignature.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
public class BigMethodSignature
2+
{
3+
public static void main(String[] args)
4+
{
5+
int value=20;
6+
printSum(value);
7+
8+
System.out.println("");
9+
}
10+
11+
public static void printSum(int value)
12+
{
13+
int sum=value+10;
14+
System.out.println("the result of adding the 10 number together:"+sum);
15+
16+
}
17+
}

ch04/Date.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
public class Date
2+
{
3+
public static void main(String[] args)
4+
{
5+
6+
7+
8+
9+
10+
11+
12+
}
13+
}

ch04/DemoMath.java

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

ch04/Employee.java

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import java.util.Random;
2+
import java.util.Scanner;
3+
4+
public class Employee
5+
{
6+
public static void main(String[] args)
7+
{
8+
int birthyear=1992;
9+
boolean isUnionMember= true;
10+
String fristname="Avi";
11+
String Lastname="Garud";
12+
String middlename="Vishwanath";
13+
int employeeNumber ;
14+
Scanner scanner=new Scanner(System.in);
15+
printHeader();
16+
System.out.println("Please enter your 5 digit employee number ");
17+
employeeNumber=scanner.nextInt();
18+
printFullName(fristname,Lastname,middlename);
19+
printUnionStatus(isUnionMember);
20+
printAge(birthyear);
21+
printEvenOrOdd(employeeNumber);
22+
printGeneratedScreatPassword(employeeNumber);
23+
}
24+
public static void printHeader()
25+
{
26+
System.out.println("Welcome to the wallabutech Employee Application");
27+
System.out.println("===============================================");
28+
}
29+
public static void printFullName(String fristname,String Lastname,String middlename)
30+
{
31+
System.out.println(Lastname+","+fristname+" "+middlename);
32+
}
33+
public static void printUnionStatus(boolean isUnioMember)
34+
{
35+
System.out.println("Your Union statues :"+isUnioMember);
36+
}
37+
public static void printAge(int birthyear)
38+
{
39+
int age=2018-birthyear;
40+
System.out.println("Your Agr is :"+age);
41+
}
42+
public static void printEvenOrOdd( int employeeNumber )
43+
{
44+
45+
System.out.println("Employee number is even /odd(1=odd,0=even:"+employeeNumber%2);
46+
}
47+
public static void printGeneratedScreatPassword(int employeeNumber)
48+
{
49+
Random random=new Random();
50+
int number =random.nextInt(10)+1;
51+
52+
int password=(employeeNumber+number)*5;
53+
System.out.println("Employee's random secreat pw is:"+password);
54+
55+
56+
}
57+
}

ch04/MathUtil.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
public class MathUtil
2+
{
3+
public static void main(String[] args)
4+
{
5+
int one=-1000;
6+
int two=400000;
7+
printDiffernace(one,two);
8+
printAbsValue(one);
9+
System.out.println();
10+
}
11+
12+
public static void printDiffernace(int one,int two)
13+
{
14+
int diff=one-two;
15+
System.out.println("the differnce between two value is"+diff);
16+
}
17+
18+
public static void printAbsValue(int one)
19+
{
20+
int abs=Math.abs(one);
21+
System.out.println("Value is :"+one+"and abs value is :"+abs);
22+
23+
}
24+
}

ch04/SImpleMethods4B3.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
public class SImpleMethods4B3
2+
{
3+
public static void main(String[] args)
4+
{
5+
Boolean isStudent;
6+
printBoolean(true);
7+
}
8+
9+
public static void printBoolean(boolean isStudent)
10+
{
11+
System.out.println("I am Student:"+isStudent);
12+
}
13+
}

ch04/SimpleMethods.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
public class SimpleMethods
2+
{
3+
public static void main(String[] args)
4+
{
5+
int count=5;
6+
printCount(count);
7+
}
8+
9+
public static void printCount(int count)
10+
{
11+
System.out.println("THe count is:"+count);
12+
}
13+
}

ch04/SimpleMethods4b2.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
public class SimpleMethods4b2
2+
{
3+
public static void main(String[] args)
4+
{
5+
int numb1=4;
6+
int numb2=6;
7+
printSum(numb1,numb2);
8+
numb1=7;
9+
numb2=2;
10+
printSum(numb1,numb2);
11+
}
12+
13+
public static void printSum(int numb1,int numb2)
14+
{
15+
16+
int sum=numb1+numb2;
17+
System.out.println("THe count is:"+sum);
18+
}
19+
20+
21+
22+
23+
}

ch04/Temp4b7.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import java.util.Scanner;
2+
public class Temp4b7
3+
{
4+
5+
6+
7+
public static void main(String[] args)
8+
{
9+
10+
11+
System.out.println("This program will convert temperature from Celsius to Faherenheit");
12+
13+
printFahrenheit();
14+
15+
16+
}
17+
public static void printFahrenheit()
18+
{
19+
Scanner scanner=new Scanner(System.in );
20+
System.out.println("Please enter the first number:");
21+
Double Celsius= scanner.nextDouble();
22+
Double Faherenheit=(Celsius*9.0/5.0)+35;
23+
24+
System.out.println("The Temperature from"+Celsius+"C="+Faherenheit+"F");
25+
}
26+
}
27+

ch04/Tongueweight.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import java.util.Scanner;
2+
public class Tongueweight
3+
{
4+
5+
6+
7+
8+
9+
public static void main(String[] args)
10+
{
11+
printRange();
12+
13+
14+
15+
16+
17+
}
18+
public static void printRange()
19+
{
20+
Scanner scanner=new Scanner(System.in);
21+
22+
System.out.println("Please enter trailer Weight ");
23+
double triweight=scanner.nextDouble();
24+
25+
System.out.println("Please enter cargo Weight ");
26+
double cargoweight=scanner.nextDouble();
27+
28+
double totalweight=triweight+cargoweight;
29+
30+
double min=0.09*totalweight;
31+
double max=0.15*totalweight;
32+
33+
System.out.println("the minimum weight "+min+"and maximum "+max+" toungue weight allowed ");
34+
35+
}
36+
37+
}

0 commit comments

Comments
 (0)