This site javatpoint is very useful for programming languages like JAVA,PYTHON,C,C++, Data Structures etc.Java learning Concept also provides technical materials , which are related to latest technologies. We provides very easy lectures to our viewers from beginning to advance level.We focus logical content instead of theoretical content.

Tuesday, 24 October 2017

STUDENT MARKS CALCULATION INPUT TO USER

Now we can discuss how can input to the user in Java. Java can be provide input to the user mainly used the following two classes.

  • Scanner clas
  • Buffer reader class
In Java programs mainly used by Scanner class because it is very simple and easy to understand. It does not require any types  constructors. 

Example : before declare a class we can import the Scanner class becabecaue scanner class inside the until package in the Java, without importanting we can not use scanner class. Then we have declared Test class. 




import  java.util.Scanner;
class Test
{
String name;
int rollno;
int hindi,eng;
int total;
float per;
void getdata()
{
Scanner sc=new Scanner(System.in);
System.out.println("enter name");
String name=sc.next();
System.out.println("enter rollno");
rollno=sc.nextInt();
System.out.println("enter marks hindi");
hindi=sc.nextInt();
System.out.println("enter marks eng");
eng=sc.nextInt();
total=hindi+ eng;
per=(total*100)/200;
System.out.println("total="+total) ;
System.out.println("per="+ per) ;

}

}
class Test1
{
public static void main(String args[])
{
Test s=new Test();
s.getdata();

}
}

Adbox