Java code find output: public class Demo { public static void main(String[] args) { double values[]={-2.3, -1.0, 0.25, 4}; int cnt = 0; for (int…
Java code find output:
public class Demo {
public static void main(String[] args) {
double values[]={-2.3, -1.0, 0.25, 4};
int cnt = 0;
for (int x=0; x < values.length; x++) {
if(Math.round(values[x]+.5) == Math.ceil(values[x])) {
++cnt;
}
}
System.out.println("same results" + cnt + " time(s)");
}
}From the BUET MSC (ICT) May 2019 – Written exam, question 3 of 20.
More from this paper
- Previous: For graph representation where there are 100 vertices and more than 300 edges, which representation (adjacency matrix or adjacency list)…
- Next: Explain the Bellman-Ford algorithm for finding shortest paths in a graph with negative edge weights.
- All questions in BUET MSC (ICT) May 2019 – Written