write a program to find out sum and average of 2 number in blue j method
Answers
Answered by
0
Answer:
Taking integer inputs
Performing mathematical operations
Printing the values on output screen
Consider the program:
// Find sum and average of two numbers in Java
import java.util.*;
public class Numbers {
public static void main(String args[]) {
int a, b, sum;
float avg;
Scanner buf = new Scanner(System.in);
System.out.print("Enter first number : ");
a = buf.nextInt();
System.out.print("Enter second number : ");
b = buf.nextInt();
/*Calculate sum and average*/
sum = a + b;
avg = (float)((a + b) / 2);
System.out.print("Sum : " + sum + "\nAverage : " + avg);
}
}
Output
Enter first number : 100
Enter second number : 200
Sum : 300
Average : 150.0
Similar questions
Science,
1 month ago
English,
1 month ago
Social Sciences,
1 month ago
Economy,
3 months ago
Math,
3 months ago
World Languages,
10 months ago
Hindi,
10 months ago
Biology,
10 months ago