Skip to content

Commit 6a02dbb

Browse files
Previous Code Examples
1 parent a27c2c4 commit 6a02dbb

File tree

6 files changed

+77
-7
lines changed

6 files changed

+77
-7
lines changed

GUI.java

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import javax.swing.JOptionPane;
2+
3+
public class GUI {
4+
public static void main(String[] args) {
5+
String name = JOptionPane.showInputDialog("Enter your name: ");
6+
JOptionPane.showMessageDialog(null, "Hello " + name);
7+
// System.out.println("Ur name is: "+ name);
8+
int age = Integer.parseInt(JOptionPane.showInputDialog("Enter your age :"));
9+
JOptionPane.showMessageDialog(null, "You are " + age + " years old");
10+
double height = Double.parseDouble(JOptionPane.showInputDialog("Entre your height"));
11+
JOptionPane.showMessageDialog(null, "You are " + height + " tall");
12+
}
13+
}

If.java

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
public class If{
2+
public static void main(String[] args){
3+
int age = 18;
4+
if (age >= 75){
5+
System.out.println("OK boomer!");
6+
}
7+
else if (age >= 18){
8+
System.out.println("You are an adult");
9+
}
10+
else{
11+
System.out.println("You are an child");
12+
}
13+
return;
14+
}
15+
}

Maths.java

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import java.util.Scanner;
2+
3+
public class Maths{
4+
public static void main(String[] args){
5+
Scanner scanner = new Scanner(System.in);
6+
System.out.println("Give the a: ");
7+
double a = Double.parseDouble(scanner.nextLine());
8+
System.out.println("Give the b :");
9+
double b = Double.parseDouble(scanner.nextLine());
10+
double c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
11+
System.out.println("The Hypotonias is: " + c);
12+
scanner.close();
13+
}
14+
15+
public static void Intro(){
16+
double x = 3.14;
17+
double y = -10;
18+
double z = Math.max(x, y); // Math.min(x, y), Math.abs(y), Math.sqrt(x), Math.round(x), Math.ceil(x), Math.floor(x)
19+
System.out.println(z);
20+
return;
21+
}
22+
}

Operators.java

-7
This file was deleted.

Randomm.java

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import java.util.Random;
2+
3+
public class Randomm{
4+
public static void main(String[] args){
5+
Random random = new Random();
6+
7+
int x = random.nextInt(8);
8+
System.out.println(x);
9+
10+
double y = random.nextDouble();
11+
return;
12+
}
13+
}

Switch.java

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
public class Switch{
2+
public static void main(String[] args){
3+
// switch is a statement that allows a variable is tested for equality
4+
String day = "Friday";
5+
switch (day){
6+
case "Sunday": System.out.println("It is Sunday!"); break;
7+
case "Monday": System.out.println("It is Monday!"); break;
8+
case "Tuesday": System.out.println("It is Tuesday!"); break;
9+
case "Wednesday": System.out.println("It is Wednesday!"); break;
10+
case "Thursday": System.out.println("It is Thursday!"); break;
11+
default: System.out.println("That is not a day! :)");
12+
}
13+
}
14+
}

0 commit comments

Comments
 (0)