import java.util.*; public class Ques1 { static Random rand = new Random(); public static void main(String[] args) { //

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

import java.util.*; public class Ques1 { static Random rand = new Random(); public static void main(String[] args) { //

Post by answerhappygod »

import java.util.*; public class Ques1 { static Random rand =
new Random(); public static void main(String[] args) { // TODO
Auto-generated method stub double ans; System.out.println("Question
1"); ans = Math.sqrt(4); System.out.printf("(a) Math.sqrt(4) =\t
%.2f%n", ans); ans = Math.sin(2 * Math.PI); System.out.printf("(b)
Math.sin(2 * Math.PI) =\t %.2f%n", ans); ans = Math.cos(2 *
Math.PI); System.out.printf("(c) Math.cos(2 * Math.PI) =\t %.2f%n",
ans); ans = Math.pow(2, 2); System.out.printf("(d) Math.pow(2, 2)
=\t %.2f%n", ans); ans = Math.log(Math.E); System.out.printf("(e)
Math.log(Math.E) =\t %.2f%n", ans); ans = Math.exp(1);
System.out.printf("(f) Math.exp(1) =\t %.2f%n", ans); ans =
Math.max(2, Math.min(3, 4)); System.out.printf("(g) Math.max(2,
Math.min(3, 4)) =\t %.2f%n", ans); ans = Math.rint(-2.5);
System.out.printf("(h) Math.rint(-2.5) =\t %.2f%n", ans); ans =
Math.ceil(-2.5); System.out.printf("(i) Math.ceil(-2.5) =\t
%.2f%n", ans); ans = Math.floor(-2.5); System.out.printf("(j)
Math.floor(-2.5) =\t %.2f%n", ans); ans = Math.round(-2.5f);
System.out.printf("(k) Math.round(-2.5f) =\t %.2f%n", ans); ans =
Math.round(-2.5); System.out.printf("(l) Math.round(-2.5) =\t
%.2f%n", ans); ans = Math.rint(2.5); System.out.printf("(m)
Math.rint(2.5) =\t %.2f%n", ans); ans = Math.ceil(2.5);
System.out.printf("(n) Math.ceil(2.5) =\t %.2f%n", ans); ans =
Math.floor(2.5); System.out.printf("(o) Math.floor(2.5) =\t
%.2f%n", ans); ans = Math.round(2.5f); System.out.printf("(p)
Math.round(2.5f) =\t %.2f%n", ans); ans = Math.round(2.5);
System.out.printf("(q) Math.round(2.5) =\t %.2f%n", ans); ans =
Math.round(Math.abs(-2.5)); System.out.printf("(r)
Math.round(Math.abs(-2.5)) =\t %.2f%n", ans); } }
Gives comments where applicable on the code
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply