Download presentation
Presentation is loading. Please wait.
1
Chapter 1 Introduction to Java
2
Exercise 1- I/O Write a Java program to input a value for mile and convert it to kilogram. 1 mile = 1.6 kg.
3
Exercise 2 - Condition Write a Java program that asks user to input the weight of a package and compute the shipping cost based on the following function: If the weight is more than 20kg, display a message that “the package cannot be shipped.”
4
Exercise 3 - Iteration Write a Java program to compute the factorial of a number input by the user.
5
Exercise 4 - Array Enter numbers: 1 2 3 2 1 6 3 4 5 3
Write a Java program that reads ten integers and store the numbers in an array. Then compute and display the number of even numbers and odd numbers. Assume that the input ends with 0. Here is the sample run of the program: Enter numbers: The number of odd numbers: 6 The number of even numbers: 4
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.