5th sem OOPJ Write a program to find length of string and print second half of the string.

import java.text.*;
import java.util.*;

/**
 *
 * @author Yash
 */

class pra4{
    public static void main(String arg[]){
        Scanner sc = new Scanner(System.in);
        DecimalFormat numfor = new DecimalFormat("#.000");//This is to fix after the decimal size.
       
        System.out.println("Enter your String :");
        String str = sc.nextLine();
        System.out.println("The Length of string is : "+str.length());
        System.out.println("Second half of string is :"+str.substring(str.length()/2,str.length()));
       
    }  
}

Comments

Popular posts from this blog

5th sem OOPJ Write an interactive program to print a diamond shape. For example, if user enters the number 3, the diamond will be as follows:

SQL Lab1: Create a Database Table for DayCare

SQL Lab 11