General Scanner function of java

   learn scanner function in Java

package com.company;
import java.sql.SQLOutput;
import java.util.Scanner;
public class intT {
public static void main(String[] arg)
{
Scanner s= new Scanner(System.in);
System.out.println("enter an integer");
boolean b= s.hasNextInt();
System.out.println(b);

}
}

km To Miles in Java

package com.company;
import java.util.Scanner;
public class kmTomiles {
public static void main(String[] arg)
{
Scanner s= new Scanner(System.in);
System.out.println("enter kilometers to convert into miles");
int a=s.nextInt();
double m = a*1.6;
System.out.print(a);
System.out.print(" miles are equal to ");
System.out.print(m);
System.out.println(" kilometers");

}
}

%age in Java

package com.company;
import java.util.Scanner;
public class Main {

public static void main(String[] args) {
Scanner s= new Scanner(System.in);
System.out.println("enter your marks");
int a=s.nextInt();
int b=s.nextInt();
int c =s.nextInt();
int d= s.nextInt();
int e= s.nextInt();
System.out.println("your persentage is ");
float s1= (a+b+c+d+e)/5;
System.out.println(s1);

}
}



No comments:

Post a Comment

    Hello, I'm Vishal Rana  I'm 19 years old  I live in Himachal Pradesh and  currently I'm studying in college for my UG degree...