Skip to content

Commit d53d768

Browse files
committed
oxoxox
1 parent dcd8ec4 commit d53d768

4 files changed

Lines changed: 117 additions & 0 deletions

File tree

ch06/.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.

ch06/Demo.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import java.util.Scanner;
2+
3+
public class Demo
4+
{
5+
public static void main(String[] args)
6+
{
7+
printGreeting("HELLO");
8+
9+
10+
Scanner in = new Scanner(System.in);
11+
12+
System.out.println("Enter a number:");
13+
14+
int firstNumber=in.nextInt();
15+
16+
System.out.println("Enter a number:");
17+
18+
int secondNumber=in.nextInt();
19+
20+
int total = firstNumber + secondNumber;
21+
System.out.println("the total is "+total);
22+
}
23+
24+
public static void printTotal()
25+
{
26+
27+
}
28+
public static void printGreeting(String greeting)
29+
{
30+
System.out.println("<<<"+ greeting + ">>>");
31+
}
32+
}

ch06/MathUtil.java

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
public class MathUtil
2+
{
3+
public static void main(String[] args)
4+
{
5+
int total = getTotal(1, 2);
6+
7+
System.out.println(total);
8+
double cargoVolume = getCargoVolume(2, 2, 2, false);
9+
System.out.println(cargoVolume);
10+
11+
int absoluteAnswer = absoluteSum(-5, 2);
12+
System.out.println(absoluteAnswer);
13+
14+
int absoluteAnswerTwo = absoluteSum(-5, 2, -3);
15+
System.out.println(absoluteAnswerTwo);
16+
17+
}
18+
19+
public static int getTotal(int firstNumber, int secondNumber)
20+
{
21+
int sum = firstNumber + secondNumber;
22+
23+
return sum;
24+
}
25+
26+
public static double getCargoVolume(double height, double length, double depth, boolean heavyDuty)
27+
{
28+
29+
double materialThickness = .25;
30+
if (heavyDuty) ;
31+
materialThickness = .25 * 2;
32+
double interiorHeight = height - (2 * materialThickness);
33+
double interiorLength = length - (2 * materialThickness);
34+
double interiorDepth = depth - (2 * materialThickness);
35+
double cargoVolume = interiorHeight * interiorLength * interiorDepth;
36+
return cargoVolume;
37+
}
38+
39+
public static int absoluteSum(int numberone, int numberTwo)
40+
{
41+
int absoluteOne = Math.abs(numberone);
42+
int absoluteTwo = Math.abs(numberTwo);
43+
int absoluteAnswer = absoluteOne + absoluteTwo;
44+
return absoluteAnswer;
45+
}
46+
47+
public static int absoluteSum(int numberone, int numberTwo, int numberThree)
48+
{
49+
int absoluteOne = Math.abs(numberone);
50+
int absoluteTwo = Math.abs(numberTwo);
51+
int absoluteThree = Math.abs(numberThree);
52+
int absoluteAnswerTwo = absoluteOne + absoluteTwo + absoluteThree;
53+
return absoluteAnswerTwo;
54+
}
55+
}

ch06/Names.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
public class Names
2+
{
3+
public static void main(String[] args)
4+
{
5+
//String decoration=%%%%%%%;
6+
String returnValue=getMyName();
7+
8+
String fancyName=getMyFancyName("%%%%%%%%");
9+
10+
System.out.println(returnValue);
11+
System.out.println(fancyName);
12+
}
13+
14+
public static String getMyName( )
15+
16+
{
17+
return "Stephen";
18+
}
19+
public static String getMyFancyName(String decoration)
20+
{
21+
String fancyName = decoration +"Stephen"+decoration;
22+
return fancyName;
23+
}
24+
}

0 commit comments

Comments
 (0)