Equation


Submit solution

Points: 10
Time limit: 5.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
C#, Go, Java

Implementa el mètode Equation.calculateSolution()

Aquest mètode ha d'emmagatzemar en la variable x la solució a l'equació:

import java.util.Scanner;

// escriu aqui el codi



public class Solution {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        Equation equation = new Equation();

        while((equation.a = scanner.nextFloat()) != 0) {
            equation.b = scanner.nextFloat();

            equation.calculateSolution();
            System.out.format("%.2f * %.2f + %.2f = 0%n", equation.a, equation.x, equation.b);
        }
    }
}

Input Format

-

Constraints

-

Output Format

-

Sample Input 0

10 5
5 10
2.5 5
0

Sample Output 0

10.00 * -0.50 + 5.00 = 0
5.00 * -2.00 + 10.00 = 0
2.50 * -2.00 + 5.00 = 0

Sample Input 1

100 500
1 5
2 10
5 25
0

Sample Output 1

100.00 * -5.00 + 500.00 = 0
1.00 * -5.00 + 5.00 = 0
2.00 * -5.00 + 10.00 = 0
5.00 * -5.00 + 25.00 = 0

Autoria: Gerard Falcó


Authorship: Gerard Falcó

CC BY-NC-SA 4.0