Menu
Question Index
...

What will be the output of the following program? Assume that the inputs as -a = 1234, b = 456, c = 789.

import java.util.Scanner;
public class TriangleLab {
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[]) {
        int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
        double s = .5 * (a + b + c);
        int area = (int) Math.sqrt(s * (s - a) * (s - b) * (s - c));
        int x = ((area * 9) + 1);
        System.out.print(area + " - " + x);
    }
}


0 - 1
992 - 8929
49053 - 441478
659372 - 5934349
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java Scanner Class Constructors With Example

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App