You are on page 1of 3

/*class first

{
public static void main(String args[])
{
int x=5,y=6;
System.out.println("Sum of "+x+" and "+y+" is: "+(x+y));
System.out.println("Difference of "+x+" and "+y+" is: "+(x-y));
System.out.println("Product of "+x+" and "+y+" is: "+(x*y));
System.out.println("Quotient of "+x+" and "+y+" is: "+((double)x/y));
}
}*/
/*class first
{
public static void main(String args[])
{
int x=5,y=6;
System.out.println("Sum of "+x+" and "+y+" is: "+(x+y));
System.out.println("Sum of "+x+" and "+y+" is: "+x+y);
System.out.println("Difference of "+x+" and "+y+" is: "+x-y);
}
}*/
/*class first
{
public static void main(String args[])
{
System.out.println(5/2); //2
System.out.println(5%2); //1
System.out.println(-5/2); //-2
System.out.println(-5%2); //-1
System.out.println(5/-2); //-2
System.out.println(5%-2); //1
System.out.println(-5/-2); //2
System.out.println(-5%-2); //-1
}
}*/
/*import java.io.*;
class first
{
public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter roll: ");
int r=Integer.parseInt(br.readLine());
System.out.println("Enter name: ");
String n=br.readLine();
System.out.println("Enter total mark: ");
double m=Double.parseDouble(br.readLine());
System.out.println("Roll: "+r+"\tName: "+n+"\tMarks: "+m);
}
}*/
/*import java.io.*;
class first
{
public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
char reply;
do
{
System.out.println("Number 1: ");
int a=Integer.parseInt(br.readLine());
System.out.println("Number 2: ");
int b=Integer.parseInt(br.readLine());
System.out.println("Press 1 to add");
System.out.println("Press 2 to subtract");
System.out.println("Choice: ");
int choi=Integer.parseInt(br.readLine());
switch(choi)
{
case 1:
System.out.println("Sum of "+a+" and "+b+" is: "+(a+b));
break;
case 2:
System.out.println("Difference of "+a+" and "+b+" is: "+(a-b));
break;
default:
System.out.println("Invalid entry...");
}
System.out.println("Do u like to continue? Press y for Yes: ");
reply=br.readLine().charAt(0);
}while(reply=='y' || reply=='Y');
}
}*/
/*
WAP to check whether a number is prime or not.
WAP to calculate number of digits and sum of digits in a number.
*/
/*class first
{
public static void main(String args[])
{
int i;
for(i=0;i<3;i++)
System.out.print(i+" ");
System.out.print(i+" ");
}
}*/
/*class first
{
public static void main(String args[])
{
int i;
for(i=0;i<3;i++);
System.out.print(i+" ");
System.out.print(i+" ");
}
}*/
/*class first
{
public static void main(String args[])
{
int i,j;
for(i=0;i<3;i++)
{
for(j=2;j>0;j--)
System.out.print(i+j);
}
System.out.print(i+j);
}
}*/
//WAP to calculate value of the expression: 1-2+3-4+....+n
/*import java.io.*;
class first
{
public static void main(String args[])throws IOException
{
int L,s=0;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter limit : ");
L=Integer.parseInt(br.readLine());
for(int i=1;i<=L;i++)
{
if(i%2==0)
s=s-i;
else
s=s+i;
}
System.out.println("Value of the expression: "+s);
}
}*/
//WAP to check whether a number is perfect number or not.
/*import java.io.*;
class first
{
public static void main(String args[])throws IOException
{
int N,s=0;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a number : ");
N=Integer.parseInt(br.readLine());
for(int i=1;i<N;i++)
{
if(N%i==0)
s=s+i;
}
if(s==N)
System.out.println(N+" is a perfect number");
else
System.out.println(N+" is not a perfect number");
}
}*/

You might also like