Program:-
https://drive.google.com/file/d/1aROzO3gDu92yOeX1vh-V6rsKcWdNCT-u/view?usp=drivesdk
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
//STRING
//String name = new String("Yash");
//or we can also write it as follwing line as a data type.
String name = "Yash";
System.out.print("My name is :");
System.out.println(name);
//DIFFERENT WAYS TO PRINT IN JAVA.
//we know the 1.System.out.println()and 2.System.out.print() there are another two ways and tgese are 3.System.out.printf() and 4.System.out.format() both 3 &4 works same.
int a = 6;
float b =5.6454f;
System.out.printf("Using printf the value of a is %d and the value of b is %f\n", a, b);
System.out.format("Using format the value of a is %d and valur of b is %f\n", a, b);
System.out.printf("Using printf thw value of a is %d and value of b is %.2f\n", a, b);
// this will print the two decimal points after the point (.) form 5.6454f
System.out.format("Using format he value of a is %d and value of b is %8.2f \n\n", a, b);
//here 8 means the 5.6454 will be writtwn in 8 spaces like:- 5.64
/*%d is use for int,byte and long.
%c is use for character
%f is use for double and float
%s is use for String*/
//taking input os String and printing it.
Scanner sc =new Scanner(System.in);
System.out.println("Enter your ne in format of 'name surname' ");
String st = sc.next();
System.out.println("your first name is :"+st);
/*String str= sc.nextLine();
System.out.println("Your surname is : +"str);*/
//these two upper lines printl the full string after the space also.
}
}
