_java_ program_
write a program to input a integer number a real number a character and a word using scanner class .
Answers
Answered by
1
Question:-
➡ Write a program to input a integer number a real number a character and a word using scanner class.
Program:-
import java.util.*;
class Java
{
public static void main(String s[])
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter a real number: ");
double n=sc.nextDouble();
System.out.print("Enter a character: ");
char ch=sc.next().charAt(0);
System.out.print("Enter a word: ");
String w=sc.next();
System.out.println("Entered Number: "+n);
System.out.println("Entered Character: "+ch);
System.out.println("Entered Word: "+w);
}
}
Similar questions