Respuesta :
Answer:
I am writing this program in JAVA and C.
Explanation:
JAVA program:
import java.util.Scanner; // to take input from user
public class IntegerFractions{
public static void main(String[] args) { // start of main() function
Scanner input= new Scanner(System.in); // creates object of Scanner
// 4 int type numbers storing integer values
int num1;
int num2;
int num3;
int num4;
/*scans and reads input from user and assign each of the four integer values to num1 num2 num3 and num4 */
num1 = input.nextInt();
num2 = input.nextInt();
num3 = input.nextInt();
num4 = input.nextInt();
// to calculate average and assign result to double type variable average
double average = (num1+num2+num3+num4)/4.0;
// to calculate product and assign result to double type variable product
double product = num1 * num2 * num3 * num4;
// to calculate product and assign result to double type variable product
double productt = ((double) num1) * num2 * num3 * num4;
/*converts the result of product and average to integer and assign result of product to integer_product and result of average to integer_average */
int integer_product = (int) product;
int integer_average = (int) average;
//displays values of int type and floating point product and average
System.out.printf("%d %d\n",integer_product,integer_average);
System.out.printf("%.3f %.3f\n",productt,average); } }
C program:
#include <stdio.h>
int main() {
// 4 int type numbers storing integer values
int num1;
int num2;
int num3;
int num4;
/*scans and reads input from user and assign each of the four integer values to num1 num2 num3 and num4 */
scanf("%d",&num1);
scanf("%d",&num2);
scanf("%d",&num3);
scanf("%d",&num4);
// to calculate average and assign result to double type variable average
double average = (num1+num2+num3+num4)/4.0;
// to calculate product and assign result to double type variable product
double product = num1 * num2 * num3 * num4;
// to calculate product and assign result to double type variable product
double productt = ((double) num1) * num2 * num3 * num4;
/*converts the result of product and average to integer and assign result of product to integer_product and result of average to integer_average */
int integer_product = (int) product;
int integer_average = (int) average;
//displays values of int type and floating point product and average
printf("%d %d\n",integer_product,integer_average);
printf("%.3lf %.3lf\n",productt,average); }
Output for both programs:
8 10 5 4
1600 6
1600.000 6.750
Output for larger values:
100000 200000 300000 500000
-1679818752 275000
3000000000000000000000.000 275000.000