# Field Manual for Hackers

## Java Write a program to calculate the grades obtained by the student.

The marks obtained by student in five different subjects are input through the keyboard.the student get division or grade as per the following rule:

•     -60% or above   ----    first class
•     -50% to  59%  ------     second class
•     -40% to  49%  ------     third class
•     -Less than 40%   ------     Fail

Write a program to calculate the grades obtained by the student.

1. import java.util.Scanner;

class Test{

public static void main(String ar[])
{

Scanner sc=new Scanner(System.in);
double g1,g2,g3,g4,g5,avg;
System.out.println("Enter Marks of First Subject");
g1=sc.nextDouble();
System.out.println("Enter Marks of Second Subject");
g2=sc.nextDouble();
System.out.println("Enter Marks of Third Subject");
g3=sc.nextDouble();
System.out.println("Enter Marks of Fourth Subject");
g4=sc.nextDouble();
System.out.println("Enter Marks of Fifth Subject");
g5=sc.nextDouble();
avg=(g1+g2+g3+g4+g5)/5;
if(avg>=60){System.out.println("First Class");}
else if(avg>=50 && avg<=59){System.out.println("Second Class");}
else if(avg>=40 && avg<=49){System.out.println("Third Class");}
else{System.out.println("Fail");}

}
}

2. import java.util.Scanner;
class Division
{
public static void main(String ar[])
{double Percentage,Subject1,Subject2,Subject3,Subject4,Subject5;
Scanner scan=new Scanner(System.in);
System.out.println("Enter marks of First subject");
Subject1=scan.nextDouble();
System.out.println("Enter marks of Second subject");
Subject2=scan.nextDouble();
System.out.println("Enter marks of Third subject");
Subject3=scan.nextDouble();
System.out.println("Enter marks of Fourth subject");
Subject4=scan.nextDouble();
System.out.println("Enter marks of Fifth subject");
Subject5=scan.nextDouble();
Percentage=(Subject1+Subject2+Subject3+Subject4+Subject5)/500*100;
if(Percentage<40)
{System.out.println("Sorry you get Fail");}
else if(Percentage>=40&&Percentage<50)
{System.out.println("you get Third class Division");}
else if(Percentage>=50&&Percentage<60)
{System.out.println("you get Second class Division");}
else if(Percentage>=60)
{System.out.println("you get First class Division");}
}}

3. import java.util.Scanner;
class Result
{
public static void main(String Args[])
{
System.out.println("enter the marks obtained in maths");
Scanner sc=new Scanner(System.in);
double maths=sc.nextDouble();
System.out.println("enter the marks obtained in physics");
double physics=sc.nextDouble();
System.out.println("enter the marks obtained in chemistry");
double chemistry=sc.nextDouble();
System.out.println("enter the marks obtained in english");
double english=sc.nextDouble();
System.out.println("enter the marks obtained in computer science");
double com=sc.nextDouble();
double percent;
percent =((maths+physics+chemistry+english+com)/5);
System.out.println("percentage obtained is"+percent);
if(percent<40)
System.out.println("FAIL");
else if(percent<50)
System.out.println("THIRD CLASS");
else if(percent<60)
System.out.println("SECOND CLASS");
else
System.out.println("FIRST CLASS");
}
}

4. import java.util.Scanner;

class Test
{

public static void main(String ar[])
{

Double a;
System.out.print("Enter marks: ");
Scanner obj=new Scanner(System.in);
a=obj.nextDouble();
if(a>100||a<0)
{ System.out.println("Invalid marks entered");
}
else if(a>=60){
System.out.println("First class");
}
else if(a>=50){
System.out.println("Second class");
}
else if(a>=40){
System.out.println("Third class");
}
else
System.out.println("Fail");
}

}

5. import java.util.Scanner;
{
public static void main(String ar[])
{
Scanner input = new Scanner(System.in);
float sub1,sub2,sub3,sub4,sub5,percentage;
System.out.println(" Enter the marks of first subject");
sub1 = input.nextFloat();
System.out.println(" Enter the marks of second subject");
sub2 = input.nextFloat();
System.out.println(" Enter the marks of third subject");
sub3 = input.nextFloat();
System.out.println(" Enter the marks of fourth subject");
sub4 = input.nextFloat();
System.out.println(" Enter the marks of fifth subject");
sub5 = input.nextFloat();
percentage =((sub1+sub2+sub3+sub4+sub5)*100)/500 ;
System.out.println("Your percentage is : " +percentage);
{
if(percentage >=60)
else
if(percentage>=50 && percentage<=59)
else
if(percentage>=40 && percentage<=49)
else
}
}
}

6. import java.util.*;
public class Marks
{
public static void main(String args[])
{
float M,H,E,S,C,sum,per;
System.out.println("Enter marks");
Scanner sc=new Scanner(System.in);
M=sc.nextFloat();
H=sc.nextFloat();
E=sc.nextFloat();
S=sc.nextFloat();
C=sc.nextFloat();
sum=M+H+E+S+C;
System.out.println("Total marks "+sum);
per=(sum*100)/500;
System.out.println("Percentage "+per);
if(per>=60)
{
System.out.println("First class");
}
if(per<60)
{
if(per>=50)
{
System.out.println("Second class");
}

}
if(per<50)
{
if(per>=40)
{
System.out.println("Third class");
}
}
if(per<40)
{
System.out.println("Fail");
}

}
}

7. import java.util.Scanner;
public static void main(String ar[]){
Scanner obj=new Scanner(System.in);
float eng,hin,math,sst,sci,per;
System.out.println("enter the marks in english,hindi,maths,sst,science respectively");
eng=obj.nextFloat();
hin=obj.nextFloat();
math=obj.nextFloat();
sst=obj.nextFloat();
sci=obj.nextFloat();
per=(eng+hin+math+sst+sci)/5;
if(per>60)
System.out.println("first class");
else if(per>=50&&per<=59)
System.out.println("second class");
else if(per>=40&&per<=49)
System.out.println("third class");
else
System.out.println("fail");
}
}

8. import java.util.Scanner;
class Result{
public static void main(String ar[]){
int s1,s2,s3,s4,s5;
double p;
Scanner scan=new Scanner(System.in);
System.out.println("Enter marks of 1st subject");
s1=scan.nextInt();
System.out.println("Enter marks of 2nd subject");
s2=scan.nextInt();
System.out.println("Enter marks of 3rd subject");
s3=scan.nextInt();
System.out.println("Enter marks of 4th subject");
s4=scan.nextInt();
System.out.println("Enter marks of 5th subject");
s5=scan.nextInt();

p=(s1+s2+s3+s4+s5)/5;

if(p>60)
System.out.println("first dividion with "+p);
else if(p>=50||p<=59){
System.out.println("second dividion with "+p);
}
else if(p>=40||p<=49){
System.out.println("third dividion with "+p);
}
else if(p<40){
System.out.println("FAIL "+p);
}

}
}

9. import java.util.Scanner;

class Marks{

public static void main(String ar[]){
double perc,eng,hin,mat,sc,sst;

Scanner scan=new Scanner(System.in);
System.out.println("Marks in English out of 100:");
eng=scan.nextDouble();

System.out.println("Marks in Hindi out of 100:");
hin=scan.nextDouble();

System.out.println("Marks in Maths out of 100:");
mat=scan.nextDouble();

System.out.println("Marks in Science out of 100:");
sc=scan.nextDouble();

System.out.println("Marks in Sst out of 100:");
sst=scan.nextDouble();

perc=(eng+hin+mat+sc+sst)/5;
System.out.println("Percentage is: "+perc+"%");

if(perc>=60){

System.out.println("First Class");
}
else if(perc>=50){
System.out.println("Second Class");
}
else if(perc>=40){
System.out.println("Third Class");
}
else{
System.out.println("Fail");
}
}
}

10. import java.util.Scanner;
public static void main(String[]ar)
{
String Name;
String Sub1,Sub2,Sub3,Sub4,Sub5;
Double GRa1,GRa2,GRa3,GRa4,GRa5,AVG;
Scanner s = new Scanner(System.in);
System.out.println("Enter user Name: \n");
Name=s.next();
System.out.println("welcome: \n"+Name);
/*System.out.println("Enter subject:\n");
Sub1=s.next();
System.out.println("Subject"+Sub1);
System.out.println("enter the marks for:");
GRa1=s.next();*/
System.out.println("Enter Marks of First Subject");
GRa1=s.nextDouble();
System.out.println("Enter Marks of Second Subject \n");
GRa2=s.nextDouble();
System.out.println("Enter Marks of Third Subject \n");
GRa3=s.nextDouble();
System.out.println("Enter Marks of Fourth Subject \n");
GRa4=s.nextDouble();
System.out.println("Enter Marks of Fifth Subject \n");
GRa5=s.nextDouble();
AVG=(GRa1+GRa2+GRa3+GRa4+GRa5)/5;
if(AVG>=60){System.out.println("First Class \n"+Name);}
else if(AVG>=50 && AVG<=59){System.out.println("Second Class \n"+Name);}
else if(AVG>=40 && AVG<=49){System.out.println("Third Class \n"+Name);}
else{System.out.println("Fail"+Name);}

}
}

11. import java.util.*;

class Student{

public static void main(String ar[]){
double perc,eng,hin,mat,sc,sst;
Scanner s=new Scanner(System.in);
System.out.println("Marks in English: ");
eng=s.nextDouble();

System.out.println("Marks in Hindi: ");
hin=s.nextDouble();

System.out.println("Marks in Maths: ");
mat=s.nextDouble();

System.out.println("Marks in Science: ");
sc=s.nextDouble();

System.out.println("Marks in Sst: ");
sst=s.nextDouble();

perc=((eng+hin+mat+sc+sst)/500)*100;
System.out.println("Percentage is: "+perc+"%");

if(perc>=60){

System.out.println("First Class");
}
else if(perc>=50){
System.out.println("Second Class");
}
else if(perc>=40){
System.out.println("Third Class");
}
else{
System.out.println("Fail");
}
}
}

12. //using and operator
import java.util.*;

class Student{

public static void main(String ar[]){
double perc,eng,hin,mat,sc,sst;
Scanner s=new Scanner(System.in);
System.out.println("Marks in English: ");
eng=s.nextDouble();

System.out.println("Marks in Hindi: ");
hin=s.nextDouble();

System.out.println("Marks in Maths: ");
mat=s.nextDouble();

System.out.println("Marks in Science: ");
sc=s.nextDouble();

System.out.println("Marks in Sst: ");
sst=s.nextDouble();

perc=((eng+hin+mat+sc+sst)/500)*100;
System.out.println("Percentage is: "+perc+"%");

if(perc>=60){

System.out.println("First Class");
}
else if(perc==50&&perc<=59){
System.out.println("Second Class");
}
else if(perc==40&&perc<=49){
System.out.println("Third Class");
}
else{
System.out.println("Fail");
}
}
}

13. package com.example.myapplication;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.VideoView;

public class Marks extends Activity {

int Eng,Hin,Math,Sic,Sst,percentage;
Button btM;
TextView tvM;
EditText eteng,ethin,etmath,etsci,etsst;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.marks);

btM=findViewById(R.id.btM);
tvM=findViewById(R.id.tvM);
eteng=findViewById(R.id.etEng);
ethin=findViewById(R.id.etHin);
etmath=findViewById(R.id.etMaths);
etsci=findViewById(R.id.etsci);
etsst=findViewById(R.id.etsst);

btM.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Eng=Integer.parseInt(eteng.getText().toString());
Hin=Integer.parseInt(ethin.getText().toString());
Math=Integer.parseInt(etmath.getText().toString());
Sic=Integer.parseInt(etsci.getText().toString());
Sst=Integer.parseInt(etsst.getText().toString());

percentage=(Eng+Hin+Math+Sst+Sic)/5;

if (percentage>=60) {

tvM.setText("First Position");
}else if (percentage>=50&&percentage<=59){

tvM.setText("Second Position");

}else if (percentage>=40&&percentage<=49){

tvM.setText("Third Position");
}else {
tvM.setText("FAIL");
}
}
});
}
}