8604. Sum and product of real numbers

 

Three real numbers are given. Find their sum and product.

 

Input. Three real numbers xyz.

 

Output. Print the sum and the product of three numbers with 4 decimal places on a single line.

 

Sample input

Sample output

1.2345 3.4566 -0.1236

4.5675 -0.5274

 

 

SOLUTION

real numbers

 

Algorithm analysis

In this problem, you need to read three real numbers, compute and print their sum and product.

 

Algorithm realization

Read three real numbers.

 

scanf("%lf %lf %lf", &a, &b, &c);

 

Compute and print the sum and the product of three numbers.

 

s = a + b + c;

p = a * b * c;

printf("%.4lf %.4lf\n", s, p);

 

Java realization

 

import java.util.Scanner;

 

class Main

{

  public static void main(String[] args)

  {

    Scanner con = new Scanner(System.in);

    double a = con.nextDouble();

    double b = con.nextDouble();

    double c = con.nextDouble();

 

    double s = a + b + c;

    double p = a * b * c;

 

    System.out.printf("%.4f %.4f",s,p);

    con.close();

  }

}

 

Python realization

Read three real numbers.

 

a, b, c = map(float, input().split())

 

Compute and print the sum and the product of three numbers.

 

print(a + b + c, a * b * c)