0% found this document useful (0 votes)
38 views

Program-13: Print String in Netbean

The document contains code snippets and outputs for 18 different Java programs. Each program has an aim, code section, and output section. The programs cover topics like printing strings, calculating averages from user input, reversing numbers, compound interest calculation, printing numeric patterns, and calculating the Fibonacci series.

Uploaded by

ratan lal mourya
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Program-13: Print String in Netbean

The document contains code snippets and outputs for 18 different Java programs. Each program has an aim, code section, and output section. The programs cover topics like printing strings, calculating averages from user input, reversing numbers, compound interest calculation, printing numeric patterns, and calculating the Fibonacci series.

Uploaded by

ratan lal mourya
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Program- 13

AIM :
Print string in netbean

CODE:
package ratan;

public class Ratan {

public static void main(String[] args) {

System.out.println("THIS IS MY FIRST PROGRAM");

OUTPUT:
Program-14
AIM:
Find the average of some number where numbers should be enter from
user

CODE:
package average;

import java.util.Scanner;

public class Average {

public static void main(String[] args) {

Scanner sc=new Scanner(System.in);

float a,b,c,d,e;

float avg;

System.out.println("enter the five digit\n");

a=sc.nextFloat();

b=sc.nextFloat();

c=sc.nextFloat();

d=sc.nextFloat();

e=sc.nextFloat();
avg=a+b+c+d+e/5;

System.out.println("average of five number:" + avg);

OUTPUT:
Program-15
AIM:
Write a program to print reverse of number

CODE:
package reverse;

import java.util.Scanner;

public class Reverse

public static void main(String[] args)

long t,r,sum=0;

Scanner sc =new Scanner(System.in);

System.out.println("Enter a number =");

t=sc.nextInt();

while(t>0)

r=t%10;

sum=10*sum+r;
t=t/10;

System.out.println("The revesing of given number is\n" + sum);

OUTPUT:
Program-16
AIM:
Write a program to find out compound interest

CODE:
package compound;

import java.io.*;

public class Compound {

public static void main(String[] args) throws Exception

float si,r,t;

int n;

BufferedReader br=new BufferedReader(new


InputStreamReader(System.in));

System.out.println("enter the years\n");

n=Integer.parseInt(br.readLine());

System.out.println("enter time\n");

t=Float.parseFloat(br.readLine());

System.out.println("enter the rate\n");

r=Float.parseFloat(br.readLine());
si=n*t*r/100;

System.out.println("simple interset:" + si );

OUTPUT:
Program-17
AIM:
Write a program to print following structures

1.
1

12

123

1234

2.
1

22

333

4444

CODE:
package num1;

import java.util.Scanner;

public class Num1{

public static void main(String[] args) {

int n,i,j,p=1;

Scanner sc=new Scanner(System.in);


System.out.println("enter number");

n=sc.nextInt();

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

for(j=1;j<=i;j++)

System.out.print(j);

System.out.print("\n");

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

for(j=1;j<=i;j++)

System.out.print(p);

p++;

System.out.print("\n");

}
}

OUTPUT:
Program-18
AIM:
Write a program to find out Fibonacci series

CODE:
package fibo;

import java.util.Scanner;

public class Fibo {

public static void main(String[] args) {

int a=0,b=1;

int n,i=1;

Scanner sc=new Scanner(System.in);

System.out.println("enter the number of term of fibonacci series");

n=sc.nextInt();

System.out.print(a + " ");

System.out.print(b + " ");

while(n>i+2)

a=a+b;
System.out.print(a + " ");

b=a+b;

System.out.print(b + " ");

i++;

OUTPUT:

You might also like