0% found this document useful (0 votes)
35 views10 pages

Java Class

The document contains multiple Java programs demonstrating various programming concepts such as variable manipulation, control structures, and user input. It includes examples for calculating factorials, determining even or odd numbers, finding the largest of three numbers, performing arithmetic operations, and checking for palindromes, among others. Additionally, it covers topics like leap years, prime numbers, and generating Fibonacci series.

Uploaded by

giridharan10436
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views10 pages

Java Class

The document contains multiple Java programs demonstrating various programming concepts such as variable manipulation, control structures, and user input. It includes examples for calculating factorials, determining even or odd numbers, finding the largest of three numbers, performing arithmetic operations, and checking for palindromes, among others. Additionally, it covers topics like leap years, prime numbers, and generating Fibonacci series.

Uploaded by

giridharan10436
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

class Main {

public static void main(String[] args) {

int a=Integer.MAX_VALUE;

int B=Integer.MIN_VALUE;

[Link](a);

[Link](B);

[Link](a+1);

[Link](B+1);

class Main {

public static void main(String[] args) {

int a=56;

[Link](a-- + --a + --a );

[Link](a);

class Main {

public static void main(String[] args) {

int a=96;

a+=90

[Link](a);

}
import [Link].*;
public class Main {
public static void main (String [] args){
Scanner S=new Scanner([Link]);

[Link]("enter the number");


int num =[Link]();
if(num%2==0){
[Link] ("even");
}
else {
[Link] ("odd");
}

}
}

import [Link].*;
public class Main {
public static void main (String [] args){
Scanner S=new Scanner([Link]);

[Link]("enter the number");


int a =[Link]();
int b =[Link]();

int c =[Link]();
if(a>b&a>c){

[Link] ("a");
}
else if (a<b&b>c) {
[Link] ("b");
}
else {
[Link] ("c");
}
}
}
import [Link];

public class Main {


public static void main (String [] args){
Scanner S=new Scanner([Link]);

[Link]("enter the number");


[Link]("enter the operator");
int a =[Link]();
int b =[Link]();
char o=[Link]().charAt(0);
switch(o) {
case '+':
[Link](a+b);
break;
case '/':
[Link](a/b);
break;
case '-':
[Link](a-b);
break;
case '*':
[Link](a*b);
break;
default:
[Link]("invalid");
break;
}

}
}

import [Link];

public class Main {


public static void main (String [] args){
int i;
Scanner S=new Scanner([Link]);

[Link]("enter the number");


int n =[Link]();
for(i=n;i>=0;i--)
{
[Link](i);

}
}
}

public class Main {


public static void main (String [] args){

//Scanner S=new Scanner([Link]);

//[Link]("enter the number");


int i=10;
while (i>=0){

[Link](i);
i--;}

}
}

public class Main {


public static void main (String [] args){

Scanner S=new Scanner([Link]);

//[Link]("enter the number");


int i=0;
do {

[Link](i);
i++;
} while (i<=10);

}
}
FACTORIAL:

import [Link];

public class Main {


public static void main (String [] args){
[Link]("enter number");
Scanner S=new Scanner([Link]);
int f=1;
int n=[Link]();
for(int i=1;i<=n;i++)
{
f=f*i;
}
[Link](f);
}
}

Multiplication table

import [Link];

public class Main {


public static void main (String [] args){
Scanner S=new Scanner([Link]);
[Link]("enter number");
int n=[Link]();
int mul;
for(int i=1;i<=10;i++)
{
mul=n*i;
[Link](n +"*" + i + "=" + mul );
}
}
}

Add of give number

import [Link].*;
public class addofgivennum {
public static void main(String[] args) {
Scanner s=new Scanner([Link]);
int a=[Link]();
int b;
b=a%9;
if(b==0){
[Link](9);
}
else {
[Link](b);
}

Reverse a number

import [Link].*;
public class revnum {
public static void main(String[] args) {
Scanner S= new Scanner([Link]);
[Link]("enter num");
String a=[Link]();
String b=" ";
for(int i=[Link]()-1;i>=0;i--)
{
b+=[Link](i);
}
[Link](b);
}
}

Palindrome

import [Link].*;
public class revnum {
public static void main(String[] args) {
Scanner S= new Scanner([Link]);
[Link]("enter num");
String a=[Link]();
String b=" ";
for(int i=[Link]()-1;i>=0;i--)
{
b+=[Link](i);
}
[Link](b);
if(a .equals(b)){
[Link]("palindrome");
}
else{
[Link]("not");
}
}
}

Triangle

import [Link].*;
public class triangle {
public static void main(String[]agrs) {
Scanner S=new Scanner([Link]);
[Link]("1 st angle");
float a=[Link]();
[Link]("2 nd angle");
float b=[Link]();
[Link]("3 th angle");
float c=[Link]();
if(a+b+c==180)
{
[Link]("valid");
}
else
{
[Link]("not valid");
}
}
}

Prime or not

import [Link].*;
public class prime {
public static void main(String[]agrs){
Scanner s=new Scanner([Link]);
[Link]("entern num");
int n=[Link]();
if(n==1)
{
[Link]("not prime and prime");
}
else if (n>=2) {
for(int i=2;i<=n;i++)
{
if( i%n!=0){
[Link](" prime");
break;
}
else{
[Link](" not ");
}
}
}

}
}

Leap year

import [Link].*;
public class leapyear{
public static void main(String[]args){
Scanner S=new Scanner([Link]);
[Link]("enter year");
int year=[Link]();
if((year%4==0&& year%100!=0) || year%400==0)
{
[Link]("leap year");
}
else{
[Link]("not leap year");
}
}
}

Vowel

import [Link].*;
public class vowel{
public static void main(String[] args) {
Scanner S= new Scanner([Link]);
[Link]("enter ");
String a=[Link]();
//String b="a,e,i,o,u ";
if([Link]("a")||[Link]("e")||[Link]("i")||[Link]("o")||
[Link]("u"))
{
[Link]("yes");
}
else
{
[Link]("no");
}
}
}
Reverse a num&palindrome

import [Link].*;
public class revnum {
public static void main(String[] args) {
Scanner S= new Scanner([Link]);
[Link]("enter num");
String a=[Link]();
String b=" ";
for(int i=[Link]()-1;i>=0;i--)
{
b+=[Link](i);
}
[Link](b);
if(a .equals(b)){
[Link]("palindrome");
}
else{
[Link]("not");
}
}
}

Fibonacci series

import [Link].*;
public class fibanacci {
public static void main(String[]args){
int a=0;
int b=1;
int c;
Scanner S=new Scanner([Link]);
[Link]("enter n");
int n=[Link]();
[Link]("0 1 ");
for(int i=1;i<=n-2;i++){
//[Link](a);
c=a+b;
[Link](c+" ");

a=b;
b=c;

}
}

You might also like