Computer Science, asked by pranavvikram3041, 5 hours ago

WAP assign values to four integers a,b,c,d and print the result in a third variable as (a+b)(c*d)

Answers

Answered by xospheregaming
0

DETAILED ANSWER

import java.util.Scanner;

class Program {

public static void main(String[] args) {

 // Create four variables.

 int a, b, c, d;

 // Create scanner object to take input.

 Scanner sc  = new Scanner(System.in);

 // Ask the user for input and fill the variables.

 System.out.print("Enter value of a: ");

 a = sc.nextInt();

 System.out.print("Enter value of b: ");

 b = sc.nextInt();

 System.out.print("Enter value of c: ");

 c = sc.nextInt();

 System.out.print("Enter value of d: ");

 d = sc.nextInt();

 // Create the result variable.

 int result;

 // Use the formula given in the question to assign

 // value to the result variable.

 result = (a + b) * (c * d);

 // Print the result.

 System.out.printf("Result of (%d+%d)(%d*%d) = %d\n", a, b, c, d, result);

}

}

Similar questions