Presentation is loading. Please wait.

Presentation is loading. Please wait.

Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved. 0136012671 1 Java Programming Practice.

Similar presentations


Presentation on theme: "Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved. 0136012671 1 Java Programming Practice."— Presentation transcript:

1 Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved. 0136012671 1 Java Programming Practice 4. Write a Java program to calculate the following formula. Where: a=8 b=6 c=5 x=2 NOTE: Use both System.out.println(….) statement and System.out.printf(….) to show your output. Output: The Result is Y=0.9032258064 The Result is Y=9.032258e-01 The Result is Y=0.903226

2 Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved. 0136012671 2 Java Programming Practice 5) Write a Java program which asks from the user the length of the edges of a right triangle as inputs and then determine the length of the hypotenuse. Output: Enter the length of edge1: 3 Enter the length of edge2: 4 The length of hypotenuse: 5

3 Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved. 0136012671 3 Java Programming Practice 6) Write a Java program to read a string as input password, then compare it with a constant default password. If they are same, print to the output console “OK”, otherwise print “Password is Not Correct”. Output: Enter the password: I like Java! Password is Not Correct!


Download ppt "Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved. 0136012671 1 Java Programming Practice."

Similar presentations


Ads by Google