0% found this document useful (0 votes)
8 views2 pages

Java IDE Basics: Prime & Fibonacci Code

The document provides instructions for using Eclipse or NetBeans to create a test project and explore features like auto suggestions and code refactoring. It includes sample Java code for generating prime numbers between 1 and 100, as well as a Fibonacci series. The exercises aim to familiarize users with debugging and basic programming concepts.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Java IDE Basics: Prime & Fibonacci Code

The document provides instructions for using Eclipse or NetBeans to create a test project and explore features like auto suggestions and code refactoring. It includes sample Java code for generating prime numbers between 1 and 100, as well as a Fibonacci series. The exercises aim to familiarize users with debugging and basic programming concepts.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Program-1

Use Eclipse or NetBeans platform and acquaint yourself with the


various menus. Create a test project, add a test class, and run it. See
how you can use auto suggestions, auto fill. Try code formatter and
code refactoring like renaming variables, methods, and classes. Try
debug step by step with a small program of about 10 to 15 lines
which contains at least one if else condition and a for loop.

// Prime Number between 1 to 100

Code :

public class PrimeNumbers {


public static void main(String[] args) {
[Link]("Prime numbers between 1 and 100 are:");

for (int num = 2; num <= 100; num++) {


int count = 0; // counter for divisors

// check how many numbers divide 'num'

for (int i = 1; i <= num; i++) {


if (num % i == 0) {
count++;
}
}

// prime numbers have exactly 2 divisors: 1 and itself


if (count == 2) {
[Link](num);
}
}
}
}
// Fibonacci Sereis

public class FibonacciSeries {


public static void main(String[] args) {
int n = 10; // number of terms
int a = 0, b = 1; // initial numbers

[Link]("Fibonacci Series up to " + n + " terms:");

for (int i = 1; i <= n; i++) {


[Link](a + " "); // print current number
int sum = a + b; // add previous two
a = b; // move forward
b = sum;
}
}
}

You might also like