Menu
Topics Index
...
`

TriangleLab


If you need explanation Read this topic

If you need Answer Take test on this topic

TriangleLab
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);
    }
}

A. 0 - 1
B. 992 - 8929
C. 49053 - 441478
D. 659372 - 5934349
E. Compilation Error or Runtime Error
Topic: Java Scanner Class Constructors With Example

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

Option c is the answer by basic computations involved . No spl methods involved

Posted by Karteek Paruchuri    2013-05-13 12:43:39


option e is the answer i.e., runtime error because no elements are present for nextInt method

Posted by Sai Lalitha Renduchintala    2013-05-13 13:49:31


Congratulations Karteek Paruchuri. You are today's daily dose winner. Please send us your mobile details and we will process the recharge tomorrow after considering the new likes.

Posted by Merit Campus    2013-05-13 15:52:50


thankyou merit campus got the recharge

Posted by Karteek Paruchuri    2013-05-14 15:31:28


© meritcampus 2019

All Rights Reserved.

Open In App