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

Java Programs

Cpp

Uploaded by

rp218242
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)
11 views2 pages

Java Programs

Cpp

Uploaded by

rp218242
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

200+ Java Programs with Outputs

1. Hello World
public class HelloWorld {

public static void main(String[] args) {

[Link]("Hello, World!");

Output: Hello, World!

2. Simple Calculator
import [Link];

public class SimpleCalculator {

public static void main(String[] args) {

Scanner sc = new Scanner([Link]);

[Link]("Enter first number: ");

double num1 = [Link]();

[Link]("Enter second number: ");

double num2 = [Link]();

[Link]("Sum: " + (num1 + num2));

Output: Sum: [calculated value]

3. Fibonacci Series
import [Link];

public class Fibonacci {

public static void main(String[] args) {


Scanner sc = new Scanner([Link]);

[Link]("Enter number of terms: ");

int n = [Link]();

int a = 0, b = 1;

[Link]("Fibonacci Series: ");

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

[Link](a + " ");

int next = a + b;

a = b;

b = next;

Output: [Fibonacci series output]

You might also like