Menu
Topics Index
...
`

Percentage formatting


If you need explanation Read this topic

If you need Answer Take test on this topic

Percentage formatting
What will be the output of the following program?
import java.util.*;
public class PercentageFormat {
    public static void main(String[] args) {
        double percentage = 75.65;
        Formatter f = new Formatter();
        f.format("%f ", percentage);
        f.format("%e ", percentage);
        System.out.println(f);
    }
}

A. 75.650000 7.56e+04
B. 75.650000 7.565000e+01
C. Compilation Error
D. Runtime Error
Topic: Java Formatting Numbers

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.

Ans is B..when we are print wth %f it wl 75.650000 6 digits aftr .   wen we are printg wth %e it wl print exponential

Posted by Uday Kumar    2014-03-26 03:39:14


ans is B. the double variable percentage value 75.65 is formatted as floating point and exponential values

Posted by Naga Sinst    2014-03-26 14:23:04


Congratulations Uday Kumar. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-03-27 04:21:49


© meritcampus 2019

All Rights Reserved.

Open In App