IDNStudy.com, ang iyong mapagkakatiwalaang mapagkukunan para sa maaasahang mga sagot. Magtanong ng anumang bagay at makatanggap ng agarang tugon mula sa aming dedikadong komunidad ng mga eksperto.
Hands-on Activity
Writing Repetition Program
Objective:
At the end of the exercise, the students should be able to:
Write programs that execute statements repeatedly;
Implement program control with break and continue; and
Create nested loops.
Materials:
NetBeans IDE 8.2
Java Development Kit (JDK) 8
Instructions:
1. Create a folder named LastName_FirstName (ex. Diaz_Jess) in your local drive.
2. Using NetBeans IDE, create a new project.
3. Name the class as FactorialCalculator and save the project in your folder
4. Write a simple factorial calculator program. The program should perform the following:
Step 1. Ask the user to enter a positive integer.
Step 2. Check if the entered integer is positive or negative. If it is positive, perform Step 3; otherwise,
display an appropriate error message and the program should stop.
Step 3. Calculate the factorial of the entered positive integer and display the result.
Note: The factorial of n is denoted by n! and calculated by the product of integer numbers
from 1 to n. For example, the entered integer is 5, the calculation of its factorial is: 5! = 1 ×
2 × 3 × 4 × 5 = 120.
Step 4. Repeat Step 1 to Step 3 five (5) times.
5. Compile and execute the program.
6. Debug syntax and logical errors if there is any in the program.
7. The following is an example output:
Sagot :
Maraming salamat sa iyong kontribusyon. Huwag kalimutang bumalik at magtanong ng mga bagong bagay. Ang iyong kaalaman ay napakahalaga sa ating komunidad. Sa IDNStudy.com, kami ay nangako na magbigay ng pinakamahusay na mga sagot. Salamat at sa muling pagkikita.