forked from AllenDowney/ThinkJavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelloMethod.java
More file actions
38 lines (32 loc) · 1.12 KB
/
HelloMethod.java
File metadata and controls
38 lines (32 loc) · 1.12 KB
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
public class HelloMethod
{
public static void main(String[] args)
{
String firstName = "Fred";
String secondName = "Wilma";
String lastName = "Flintstone";
printHelloWorld(firstName, lastName);
printHelloWorld(secondName, lastName);
int firstNum = 5;
int secondNum = 10;
printOhNo(firstName, firstNum, secondNum, false);
printNumberNoSign(5);
printNumberNoSign(-5);
}
public static void printNumberNoSign (int number)
{
int positiveNumber = Math.abs(number);
System.out.println("The number is " + positiveNumber);
}
public static void printHelloWorld(String fName, String lName)
{
System.out.println("Hello, World " + fName + " " + lName + ".");
}
public static void printOhNo(String cat, int firstNumber, int secondNumber, boolean isAPerson)
{
System.out.println("Oh no!");
System.out.println("First Number is " + firstNumber);
System.out.println("Second Number is " + secondNumber);
System.out.println("Total is " + (firstNumber + secondNumber));
}
}