Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaapplication30;
- import java.lang.Math;
- public class JavaApplication30 {
- /* public static void equation(double a, double b, double c){
- double D = Math.pow(b, 2) - (4 * a * c);
- if (D < 0) {
- System.out.println("No solutions: D < 0.");
- } else if (D == 0) {
- System.out.print("There is one solution (D = 0): x = ");
- double x = -b / (c * a);
- System.out.println(x);
- } else if (D > 0) {
- System.out.println("There are two solutions (D > 0): x1 = ");
- double x1 = (-b + Math.sqrt(D)) / 2 * a;
- System.out.print(x1 + ", x2 = ");
- double x2 = (-b - Math.sqrt(D)) / 2 * a;
- System.out.println(x2);
- }
- }*/
- /* public static void evenNumbers(int low, int high) {
- System.out.print("Even numbers in [" + low + ", " + high + "]: ");
- for (int i = low; i <= high; i++) {
- if (i % 2 == 0){
- System.out.print(i + " ");
- }
- }
- System.out.println("");
- }*/
- /*public static double average(int low, int high) {
- double sum = 0;
- int counter = 0;
- for (double i = low; i <= high; i++) {
- if ((i % 5 == 0) && (i % 3 != 0)){
- sum += i;
- counter += 1;
- }
- }
- double average = sum / counter;
- System.out.println("Average: " + average);
- return average;
- }*/
- public static int sumOfDividers(int number) {
- int sum = 0;
- for (int i = 0; i < number; i++) {
- if ((i > 0) && (number % i == 0)) {
- //System.out.print(i + " ");
- sum += i;
- }
- }
- System.out.println("Sum of dividers = " + sum);
- return sum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement