Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

/**

* Created by akshay on 11/9/2016.


*/
public class markswitch {

public static void main(String[] args) {

int sub1,sub2,sub3;
int totalmarks=0;
double percentage=0.0;

Scanner sc = new Scanner(System.in);


System.out.println("Enter marks obtained in subject 1");
sub1 = sc.nextInt();
System.out.println("Enter marks obtained in subject 2");
sub2 = sc.nextInt();
System.out.println("Enter marks obtained in subject 3");
sub3 = sc.nextInt();

totalmarks = sub1 + sub2 + sub3;


percentage = totalmarks/3;

int trump = (int) (percentage/10);

switch(trump) {
case 0:
case 1:
case 2:
case 3:
System.out.println("The student has failed with" + percentage + "%"
+ "and total marks=" + totalmarks);
break;
case 4:
System.out.println(" D Grade with" + percentage + "%" + "total
marks=" + totalmarks);
break;
case 5:
System.out.println(" C Grade with" + percentage + "%" + "total
marks=" + totalmarks);
break;
case 6:
System.out.println(" B Grade with" + percentage + "%" + "total
marks=" + totalmarks);
break;
case 7:
case 8:
case 9:
System.out.println(" A Grade with" + percentage + "%" + "total
marks=" + totalmarks);
break;
default:
System.out.println("FULL BABY 100/100");
break;
}

PDF created with pdfFactory Pro trial version www.pdffactory.com


import java.util.Scanner;

/**
* Created by akshay on 11/9/2016.
*/
public class Arithmeticop {

public static void main(String[] args) {


int a ;
int b ;
int nigga;

Scanner sc = new Scanner(System.in);


System.out.println("Enter a");
a = sc.nextInt();
System.out.println("Enter b");
b = sc.nextInt();
System.out.println("Select the function you want to perform?");
nigga = sc.nextInt();

switch(nigga)
{
case 0 :
System.out.println("Add = " + a+b);
break;
case 1 :
System.out.println("Subtract=" + (a-b));
break;
case 2 :
System.out.println("Multiply = " + a*b);
break;
case 3 :
System.out.println("Quotient = " + a/b);
break;
case 4 :
System.out.println("Reminder = " + a%b);
break;
default:
System.out.println("GO DIE");
break;

}
}

PDF created with pdfFactory Pro trial version www.pdffactory.com


import java.util.Scanner;

/**
* Created by akshay on 11/9/2016.
*/
public class marksifelse {

public static void main(String[] args) {

int sub1,sub2,sub3;
int totalmarks=0;
double percentage=0.0;

Scanner sc = new Scanner(System.in);


System.out.println("Enter marks obtained in subject 1");
sub1 = sc.nextInt();
System.out.println("Enter marks obtained in subject 2");
sub2 = sc.nextInt();
System.out.println("Enter marks obtained in subject 3");
sub3 = sc.nextInt();

totalmarks = sub1 + sub2 + sub3;


percentage = totalmarks/3;

if ( percentage >= 70 && percentage <=100)


{
System.out.println("Congratulations you have passed with A grade");
}
else if ( percentage >= 60 && percentage <=69)
{
System.out.println("Congratulations you have passed with B grade");
}
else if ( percentage >= 50 && percentage <=59)
{
System.out.println("Congratulations you have passed with C grade");
}
else if ( percentage >= 40 && percentage <=49)
{
System.out.println("Congratulations you have passed with D grade");
}
else {
System.out.println("FAIL");
}

PDF created with pdfFactory Pro trial version www.pdffactory.com


import java.util.Scanner;

/**
* Created by akshay on 11/9/2016.
*/
public class monthname {

public static void main(String[] args) {


int monthno;
Scanner sc = new Scanner(System.in);
System.out.println("Enter the month number");
monthno = sc.nextInt();

switch (monthno) {

case 1:
System.out.println("JAN");
break;
case 2:
System.out.println("FEB");
break;
case 3:
System.out.println("MAR");
break;
case 4:
System.out.println("APR");
break;

case 5:
System.out.println("MAY");
break;
case 6:
System.out.println("JUN");
break;
case 7:
System.out.println("JUL");
break;
case 8:
System.out.println("AUG");
break;
case 9:
System.out.println("SEP");
break;
case 10:
System.out.println("OCT");
break;
case 11:
System.out.println("NOV");
break;
case 12:
System.out.println("DEC");
break;
default:
System.out.println("PLIZ DYE NIGGUS");
break;
}

}
}

PDF created with pdfFactory Pro trial version www.pdffactory.com


import java.util.Scanner;

/**
* Created by akshay on 11/9/2016.
*/
public class monthdays {

public static void main(String[] args) {


int monthno;
Scanner sc = new Scanner(System.in);
System.out.println("Enter the month number");
monthno = sc.nextInt();

switch (monthno) {

case 1:
System.out.println("JAN has 31 days");
break;
case 2:
System.out.println("FEB has 28 days");
break;
case 3:
System.out.println("MAR has 31 days");
break;
case 4:
System.out.println("APR has 30 days");
break;

case 5:
System.out.println("MAY has 31 days");
break;
case 6:
System.out.println("JUN has 30 days");
break;
case 7:
System.out.println("JUL has 31 days");
break;
case 8:
System.out.println("AUG has 31 days");
break;
case 9:
System.out.println("SEP has 30 days");
break;
case 10:
System.out.println("OCT has 31 days");
break;
case 11:
System.out.println("NOV has 30 days");
break;
case 12:
System.out.println("DEC has 31 days");
break;
default:
System.out.println("PLIZ DYE NIGGUS");
break;
}
}
}

PDF created with pdfFactory Pro trial version www.pdffactory.com


import java.util.Scanner;

/**
* Created by akshay on 11/9/2016.
*/
public class monthnumber {

public static void main(String[] args) {


String monthname;
Scanner sc = new Scanner(System.in);
System.out.println("Enter the month name");
monthname = sc.nextLine();

if (monthname.equals("JAN")) {
System.out.println("JAN 1");

} else if (monthname.equals("FEB")) {
System.out.println("FEB 2");

} else if (monthname.equals("MAR")) {
System.out.println("MAR 3");

} else if (monthname.equals("APR")) {
System.out.println("APR 4");

} else if (monthname.equals("MAY")) {
System.out.println("MAY 5");

} else if (monthname.equals("JUN")) {
System.out.println("JUN 6");

} else if (monthname.equals("JUL")) {
System.out.println("JUL 7");

} else if (monthname.equals("AUG")) {
System.out.println("AUG 8");

} else if (monthname.equals("SEP")) {
System.out.println("SEP 9");

} else if (monthname.equals("OCT")) {
System.out.println("OCT 10");

} else if (monthname.equals("NOV")) {
System.out.println("NOV 11");

} else if (monthname.equals("DEC")) {
System.out.println("DEC 12");

} else {
System.out.println("PLIZ DYE NIGGUS");

}
}
}

PDF created with pdfFactory Pro trial version www.pdffactory.com


import java.util.Scanner;

/**
* Created by akshay on 11/9/2016.
*/
public class ternaryop {

public static void main(String[] args) {

int a, b, c, big;

Scanner sc = new Scanner(System.in);


System.out.println("Enter a");
a= sc.nextInt();
System.out.println("Enter b");
b= sc.nextInt();
System.out.println("Enter c");
c= sc.nextInt();

big = a > b ? (a > c ? a : c) : (b > c ? b : c);

System.out.println("The largest Number is "+ big);

}
}

PDF created with pdfFactory Pro trial version www.pdffactory.com


import java.util.Scanner;

/**
* Created by akshay on 11/9/2016.
*/
public class Smallestofthreenosif
{
public static void main(String args[])
{
int x, y, z;
System.out.println("Enter three integers ");
Scanner in = new Scanner(System.in);
System.out.println("Enter x");
x = in.nextInt();
System.out.println("Enter y");
y = in.nextInt();
System.out.println("Enter z");
z = in.nextInt();

if ( x < y && x < z )


System.out.println("First number is Smallest.");
else if ( y < x && y < z )
System.out.println("Second number is Smallest.");
else if ( z < x && z < y )
System.out.println("Third number is Smallest.");
else
System.out.println("DUNIYA BOHOT MATLABI HAI MERE DOST.");
}

PDF created with pdfFactory Pro trial version www.pdffactory.com


import java.util.*;

/**
* Created by akshay on 11/9/2016.
*/
public class series1 {

public static void main(String[] args) {


int n, i, fact = 1;
double sum = 0.0;
System.out.print("Enter the value of n : ");
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
for (i = 1; i <= n; i++) {
fact = fact * i;
sum = sum + 1.0/fact;
}
System.out.println("The value of the seires is"+ sum);
}
}

PDF created with pdfFactory Pro trial version www.pdffactory.com


import java.util.Scanner;

/**
* Created by akshay on 11/9/2016.
*/
public class Pattern1 {

public static void main(String[] args) {

int n, i, j, k;
Scanner sc = new Scanner(System.in);
System.out.println("How many row you want: ");
n = sc.nextInt();
for (i = 1; i <= n; i++) {
for (k = 0; k <= n - i; k++) {
System.out.print(" ");
}

for (j = n; j >= k; j--) {


System.out.print("*");
}

System.out.print("\n");
}

for(i=1;i<=n-1;i++)
{
for(k=0;k<=i;k++)
{
System.out.print(" ");
}

for(j=n-1;j>=i;j--)
{
System.out.print("*");
}

System.out.print("\n");
}

PDF created with pdfFactory Pro trial version www.pdffactory.com


/**
* Created by akshay on 11/9/2016.
*/
public class Pattern2 {

public static void main(String[] args) {

int i, j, k;
for(i=1;i<=5;i++)
{
for(j=i;j<5;j++)
{
System.out.print(" ");
}
for(k=1;k<(i*2);k++)
{
System.out.print("*");
}
System.out.print("\n");
}
for(i=4;i>=1;i--)
{
for(j=5;j>i;j--)
{
System.out.print(" ");
}
for(k=1;k<(i*2);k++)
{
System.out.print("*");
}
System.out.print("\n");
}
}

PDF created with pdfFactory Pro trial version www.pdffactory.com


import java.util.Scanner;

/**
* Created by akshay on 11/9/2016.
*/
public class Pattern3 {

public static void main(String args[])


{
Scanner scr=new Scanner(System.in);
int n;
System.out.println("Enter the number of rows. ");
n=scr.nextInt();

char c;
for(int i=1;i<=n;++i)
{
c='A';
for(int j=i;j<n;++j)
{
System.out.print(" ");
}
for(int k=1;k<=i;++k)
{
System.out.print(c);
++c;
}
c-=2;
for(int l=1;l<i;++l)
{
System.out.print(c);
--c;
}
System.out.println();

}
}

PDF created with pdfFactory Pro trial version www.pdffactory.com


import java.util.Scanner;

/**
* Created by akshay on 11/9/2016.
*/
public class Reverse {

public static void main(String args[]) {


int n, reverse = 0;

System.out.println("Enter the number to reverse");


Scanner in = new Scanner(System.in);
n = in.nextInt();

while (n != 0) {
reverse = reverse * 10;
reverse = reverse + n % 10;
n = n / 10;
}

System.out.println("Reverse of entered number is " + reverse);


}
}

PDF created with pdfFactory Pro trial version www.pdffactory.com


import java.util.Scanner;

/**
* Created by akshay on 11/9/2016.
*/
public class Primeornot {

public static void main(String[] args) {

int temp;
boolean isPrime = true;
Scanner scan = new Scanner(System.in);
System.out.println("Enter a number for check:");

int num = scan.nextInt();


for (int i = 2; i <= num / 2; i++) {
temp = num % i;
if (temp == 0) {
isPrime = false;
break;
}
}

if (isPrime)
System.out.println(num + " is Prime Number");
else
System.out.println(num + " is not Prime Number");
}
}

PDF created with pdfFactory Pro trial version www.pdffactory.com


import java.util.Scanner;

/**
* Created by akshay on 11/9/2016.
*/
public class Sumdigit {

public static void main(String[] args) {

int i,a=0, sum=0;


Scanner sc = new Scanner(System.in);
i = sc.nextInt();
while(i!=0)
{
a=i%10;
i=i/10;
sum=sum+a;
}
System.out.println(sum);
}
}

PDF created with pdfFactory Pro trial version www.pdffactory.com


/**
* Created by akshay on 11/9/2016.
*/
public class LCM {

public static void main(String[] args) {

int a = 36;
int b = 92;
int big;
int small;

System.out.println("the value of a:" + a);

System.out.println("the value of b:" + b);


{
if (a > b)
{
big = a;
small = b;
} else {
big = b;
small = a;
}
for (int i = 1; i <= big; i++) {
if (((big * i) % small) == 0) {
int lcm = big * i;
System.out.println("The least common multiple is " + (lcm));

break;

}
} }

PDF created with pdfFactory Pro trial version www.pdffactory.com


import java.util.Scanner;

/**
* Created by akshay on 11/9/2016.
*/
public class GCD {

public static void main(String args[])throws Exception


{
Scanner sc = new Scanner(System.in);
System.out.print("Enter the First no : ");
int n1=sc.nextInt();
System.out.print("Enter the Second no : ");
int n2=sc.nextInt();
int r;

while(n2 != 0)
{
r = n1 % n2;
n1 = n2;
n2 = r;
}
System.out.print("GCD = "+n1);
}
}

PDF created with pdfFactory Pro trial version www.pdffactory.com

You might also like