Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 Write the following mathematical expressions in Java. (1) s = s 0 + v 0 t + 1/2 gt 2 (3) F V =

1 Write the following mathematical expressions in Java.

(1) s = s0 + v0t +1/2 gt2 (3) F V = P V (1 +INT/100 )Y RS

(2) G = 4 (a3/p2(m1 + m2)) (4) c = a2 + b2 2ab cos

2 What are the values of the following expressions? In each line, assume that

String s = " Hello ";

String t = " World ";

Evaluate the following expressions:

a. s . length () + t . length ()

b. s . substring (1 , 2)

c. s . substring ( s . length () / 2 , s . length ())

d. s + t

e. t + s

3. Suppose that x, y, and z are int variables and x = 10, y = 15, and z = 20. Determine whether the following expressions evaluates to true or false.

a. !( x > 10)

b. x <= 5 || y < 15

c. ( x != 5) && ( y != z )

d. x >= z || ( x + y >= z )

e. ( x <= y - 2) && ( y >= z ) || (z - 2 != 20)

4. Rewrite the following expressions using the conditional operator. (Assume that all variables are declared properly.)

(a )

if (x >= y )

z = x - y ;

else

z = y - x ;

(b )

if ( hours >= 40.0)

wages = 40 * 7.50 + 1.5 * 7.5 * ( hours - 40);

else

wages = hours * 7.50;

(c )

if ( score >= 60)

str = " Pass ";

else

str = " Fail ";

5 How many times will each of the following loops execute? What is the output in each case?

(a) x = 5; y = 50;

do

x = x + 10;

while (x < y );

System . out . println ( x + " " + y );

(b) x = 5; y = 80;

do

x = x * 2;

while (x < y );

System . out . println ( x + " " + y );

(c) x = 5; y = 20;

do

x = x + 2;

while (x >= y );

System . out . println ( x + " " + y );

(d) x = 5; y = 35;

while (x < y )

x = x + 10;

System . out . println ( x + " " + y );

(e) x = 5; y = 30;

while (x <= y )

x = x * 2;

System . out . println ( x + " " + y );

(f) x = 5; y = 30;

while (x > y )

x = x + 2;

System . out . println ( x + " " + y );

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Database Programming With Visual C# .NET

Authors: Ying Bai

1st Edition

0470467274, 978-0470467275

More Books

Students also viewed these Databases questions

Question

In Problems , (A) Form the dual problem. Discuss.

Answered: 1 week ago

Question

Describe various ways that individuals perceive change.

Answered: 1 week ago