The Java Math class + exercises! 📐

preview_player
Показать описание
#java #javatutorial #javacourse

00:00:00 intro
00:00:10 constants
00:00:57 methods
00:04:24 exercise1
00:08:27 exercise2
00:13:25 printf

public class Main {
public static void main(String[] args) {

double result;

}
}

public class Main {
public static void main(String[] args) {


double a;
double b;
double c;

}
}

public class Main {
public static void main(String[] args) {

// circumference = 2 * Math.PI * radius;

double radius;
double circumference;
double area;
double volume;

circumference = 2 * Math.PI * radius;

}
}
Рекомендации по теме
Комментарии
Автор

public class Main {
public static void main(String[] args) {

System.out.println(Math.PI);
System.out.println(Math.E);

double result;

result = Math.pow(3, 4);
result = Math.abs(-5);
result = Math.sqrt(16);
result = Math.round(3.14);
result = Math.ceil(3.14);
result = Math.floor(3.14);
result = Math.max(10, 20);
result = Math.min(10, 20);

System.out.println(result);
}
}

import java.util.Scanner;

public class Main {
public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

double a;
double b;
double c;

System.out.print("Enter the length of side A: ");
a = scanner.nextDouble();

System.out.print("Enter the length of side B: ");
b = scanner.nextDouble();

c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));

System.out.println("The hypotenuse is: " + c + "cm");

scanner.close();
}
}

import java.util.Scanner;

public class Main {
public static void main(String[] args) {

// circumference = 2 * Math.PI * radius;
// area = Math.PI * Math.pow(radius, 2);
// volume = (4.0 / 3.0) * Math.PI * Math.pow(radius, 3)

Scanner scanner = new Scanner(System.in);

double radius;
double circumference;
double area;
double volume;

System.out.print("Enter the radius: ");
radius = scanner.nextDouble();

circumference = 2 * Math.PI * radius;
area = Math.PI * Math.pow(radius, 2);
volume = (4.0 / 3.0) * Math.PI * Math.pow(radius, 3);

System.out.printf("The circumference is: %.1fcm\n", circumference);
System.out.printf("The area is: %.1fcm²\n", area);
System.out.printf("The volume is: %.1fcm³\n", volume);

scanner.close();
}
}

BroCodez