Friday, October 22, 2021

Mathematical expressions in Java

 In this task, you are being asked to understand the conversion of mathematical expressions into Java code.

Mathematical expressions in Java


1. public class Lab4Task2{

public static void main(String[] args) {

double s, s0, v0, t, g;


s0 = 12;

v0 = 24;

t = 50;

g = 9.0;


s = s0 + v0 * t + 1/2 * g * Math.pow(t,2);

System.out.println(s);

}}


2. public class Lab4Tak2{

public static void main(String[] args) {

double FV, PV, YRS, INT;

PV = 5.5;

YRS = 2;

INT = 500;

FV = PV *Math.pow(1 + INT / 100 , YRS);

System.out.println(FV);

}}


3. public class Lab4Tsk2{

public static void main(String[] args) {

double G, a, p, m1, m2;

a = 4;

p = 6;

m1 = 7;

m2 = 9;

G = 4 * Math. pi   * Math.pow(a,3) / Math.pow(p,2) * (m1 + m2);

System.out.println(G);

}}

No comments:

Post a Comment

String Array and passing method in java

 In this task, we pass a method and also cover the passing String Array to the method. Code:   import java.util.Scanner; public class String...