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 7. Write a Java program to calculate the and print the roots of a quadratic equation. Program Output: Enter The a coefficient 2 Enter The b coefficient -6 Enter The c coefficient 3 The Roots are: X1 = 2.366025, X2 = 0.633975

2 Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved. 0136012671 2 Java Programming Practice 8) Write a Java program which asks from the user the weight in kilograms and the height in meters as input and then calculates Body Mass Index (BMI) with the formula BMI = weight / (height 2 ) and print the result with the corresponding comment according to the following table. Output: Enter the weight in kg: 60 Enter the height in meters: 1.5 The BMI is 26.666667 So, it is overweight

3 Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved. 0136012671 3 Java Programming Practice 9. Write a Java program to convert weekdays number to the weekdays name. (Use case Command) Output: Enter Weekday Number: 0 Day is Monday Enter Weekday Number: 2 Day is Wednesday Enter Weekday Number: 6 Day is Sunday Enter Weekday Number: 3 Day is Thursday


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