-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExampleJavaClass.java
More file actions
42 lines (31 loc) · 1.13 KB
/
Copy pathExampleJavaClass.java
File metadata and controls
42 lines (31 loc) · 1.13 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
39
40
41
42
import book.Book;
import book.EBook;
public class ExampleJavaClass {
// A simple function that returns a greeting message
public static String getGreeting(String name) {
return "Hello, " + name + "!";
}
// A function that adds two numbers and returns the sum
public static int addNumbers(int a, int b) {
return a + b;
}
// A function that checks if a number is even
public static boolean isEven(int number) {
return number % 2 == 0;
}
// A function that checks if a number is even
public static Book newBook(int number) {
Book book = new Book("1984", "George Orwell");
return book;
}
// The main method to test the functions
public static String main(String[] args) {
System.out.println(getGreeting("Alice"));
System.out.println("Sum of 5 and 3: " + addNumbers(5, 3));
return "Is 10 even? " + isEven(10);
// Book book = new Book("1984", "George Orwell");
// EBook ebook = new EBook("Brave New World", "Aldous Huxley", 1.5);
// book.displayInfo();
// ebook.displayInfo();
}
}