CSS
import java.io.*; class Prog1 { public static void main(String args[]) { System.out.println("Hello Java World!"); System.out.println("KKCC INFO SYSTEMS"); System.out.println("Ongole"); } }
import java.io.*; import java.util.*; class Prog2 { public static void main(String args[]) { Scanner in=new Scanner(System.in); int a,b,c; System.out.println("Enter a,b values"); a=in.nextInt(); b=in.nextInt(); c=a+b; System.out.println("A=" + a); System.out.println("B=" + b); System.out.println("Sum=" + c); } }
//w.a.p to read radius and print its area import java.io.*; import java.util.*; class Prog3 { public static void main(String args[]) { Scanner in=new Scanner(System.in); float r,pi=3.1416f,area; System.out.println("Enter radius value"); r=in.nextFloat(); area=pi*r*r; System.out.println(r + " Area is " + area); } }
import java.io.*; import java.util.*; class Prog4 { public static void main(String args[]) { int m,p,c,avg,sum=0; Scanner in=new Scanner(System.in); System.out.println("Enter m,p,c values"); m=in.nextInt(); p=in.nextInt(); c=in.nextInt(); sum=m+p+c; avg=(sum/3); if(m>34 && c>34 && p>34 ) { if(avg>34 && avg<50) { System.out.println("Ordianary"); } else if(avg>=50 && avg<60) { System.out.println("Second class"); } else if(avg>=60 && avg<75) { System.out.println("First Class"); } else if(avg>=75 && avg<=100) { System.out.println("Distinction"); } else if(avg>100) { System.out.println("Given Marks is Wrong"); } } else { if(m<35) System.out.print("Maths "); if(p<35) System.out.print("Phy "); if(c<35) System.out.print("Che "); System.out.print(" Failed"); } } }
//w.a.p to read any number and print table import java.io.*; import java.util.Scanner; class Prog5 { public static void main(String args[]) { int n,i; Scanner in=new Scanner(System.in); System.out.println("Enter n value"); n=in.nextInt(); i=1; while(i<=10) { System.out.println(n + "X" + i + "=" + n*i); i++; } } }
/* 1 12 123 1234 12345 */ import java.io.*; import java.lang.*; import java.util.*; class Prog6 { public static void main(String args[]) { int n; Scanner scanner=new Scanner(System.in); System.out.println("Enter any number"); n=scanner.nextInt(); for(int i=1;i<=n;i++) { for(int j=1;j<=i;j++) { System.out.print( i + " "); // System.out.print( j + " "); // System.out.print( "* "); // System.out.print( (char) (64+j)); } System.out.println(""); } } }
import java.io.*; import java.util.*; class Prog7 { public static void main(String args[]) { int amount,sum=0; Scanner in=new Scanner(System.in); do { System.out.println("Enter Amount"); amount=in.nextInt(); if(amount>0) { sum=sum+amount; System.out.println("Cumilative Amount is :" + sum); } }while(amount>0); System.out.println("The Total Amount is " + sum); } }
import java.io.*; import java.util.*; class Prog8 { public static void main(String args[]) { int a,b,c; Scanner in=new Scanner(System.in); System.out.println("Enter a,b values"); a=in.nextInt(); b=in.nextInt(); do{ System.out.println("1.Addition"); System.out.println("2.Subtraction"); System.out.println("3.Multiplication"); System.out.println("4.Division"); System.out.println("5.Modulus"); System.out.println("6.Exit"); System.out.println("Enter Your Choice "); c=in.nextInt(); switch(c) { case 1: System.out.println("A+B=" + (a+b)); break; case 2: System.out.println("A-B=" + (a-b)); break; case 3: System.out.println("AXB=" + (a*b)); break; case 4: System.out.println("A/B=" + (a/b)); break; case 5: System.out.println("A%B=" + (a%b)); break; default: System.out.println("Your Exit"); } }while(c<=5); } }
import java.io.*; import java.util.*; class Prog9 { public static void main(String args[]) { int a[],n; Scanner scanner=new Scanner(System.in); System.out.println("Enter n value"); n=scanner.nextInt(); a=new int[n]; System.out.println("Enter " + n + " Elements"); for(int i=0;i
import java.io.*; import java.util.*; class Prog10 { public static void main(String args[]) { int a[][],r,c; Scanner scanner=new Scanner(System.in); System.out.println("Enter row and column values"); r=scanner.nextInt(); c=scanner.nextInt(); a=new int[r][c]; System.out.println("Enter " + r + "X" + c + " values"); for(int i=0;i
//No Arguments Pass and No Return values import java.io.*; import java.util.*; class Prog11 { static void area() { float r,pi=3.1416f,a; Scanner in=new Scanner(System.in); System.out.println("Enter radius value"); r=in.nextFloat(); a=pi*r*r; System.out.println(r + " Area is " + a); } public static void main(String args[]) { int n,i; Scanner in=new Scanner(System.in); System.out.println("Enter n value"); n=in.nextInt(); for(i=1;i<=n;i++) { area(); } } }
// Arguments Pass But No Return values import java.io.*; import java.util.*; class Prog12 { public static void area(float r) { float pi=3.1416f,a; a=pi*r*r; System.out.println(r + " Area is " + a); } public static void main(String args[]) { int n,i; float r; Scanner in=new Scanner(System.in); System.out.println("Enter n value"); n=in.nextInt(); for(i=1;i<=n;i++) { System.out.println("Enter Radius value"); r=in.nextFloat(); area(r); } } }
// Arguments Pass and Return values import java.io.*; import java.util.*; class Prog13 { public static float area(float r) { float pi=3.1416f,a; a=pi*r*r; return(a); } public static void main(String args[]) { int n,i; float r,a; Scanner in=new Scanner(System.in); System.out.println("Enter n value"); n=in.nextInt(); for(i=1;i<=n;i++) { System.out.println("Enter Radius value"); r=in.nextFloat(); a=area(r); System.out.println(r + " Area is " + a); } } }
// No Arguments Pass But Return values import java.io.*; import java.util.*; class Prog14 { public static float area() { float r,pi=3.1416f,a; Scanner in=new Scanner(System.in); System.out.println("Enter Radius value"); r=in.nextFloat(); a=pi*r*r; System.out.print(r); return(a); } public static void main(String args[]) { int n,i; float a; Scanner in=new Scanner(System.in); System.out.println("Enter n value"); n=in.nextInt(); for(i=1;i<=n;i++) { a=area(); System.out.println(" Area is " + a); } } }
/* Functions Overloading ? The function name is the common and the parameters is different is called a functions overloading */ import java.io.*; import java.util.*; class Prog15 { public static int sum(int arg1,int arg2) { return(arg1+arg2); } public static int sum(int arg1,int arg2,int arg3) { return(arg1+arg2+arg3); } public static int sum(int arg1,int arg2,int arg3,int arg4) { return(arg1+arg2+arg3+arg4); } public static float sum(int arg1,float arg2) { return(arg1+arg2); } public static float sum(float arg1,int arg2) { return(arg1+arg2); } public static float sum(float arg1,float arg2) { return(arg1+arg2); } public static void main(String args[]) { int a,b,c,d; float e,f; Scanner in=new Scanner(System.in); System.out.println("Enter any four Integers"); a=in.nextInt(); b=in.nextInt(); c=in.nextInt(); d=in.nextInt(); System.out.println("Enter any two Float numbers"); e=in.nextFloat(); f=in.nextFloat(); System.out.println("A+B=" + sum(a,b)); System.out.println("A+B+C=" + sum(a,b,c)); System.out.println("A+B+C+D=" + sum(a,b,c,d)); System.out.println("A+E=" + sum(a,e)); System.out.println("E+A=" + sum(e,a)); System.out.println("E+F=" + sum(e,f)); } }
/* What is the Class ? The combination state and behaviour of the object is called class What is the Object ? A instance of the class is called object */ import java.io.*; import java.util.*; class Student { int code; String name; String course; public void setStudent(int intcode,String strname,String strcourse) { code=intcode; name=strname; course=strcourse; } public void showStudent() { System.out.println("Code : " +code); System.out.println("Name : " +name); System.out.println("Course : " +course); } } class Prog16 { public static void main(String args[]) { Student student1=new Student(); Student student2=new Student(); int code; String name,course; Scanner in=new Scanner(System.in); System.out.println("Enter Code Name Course"); code=in.nextInt(); name=in.next(); course=in.next(); student1.setStudent(code,name,course); System.out.println("Enter Code Name Course for Student 1"); code=in.nextInt(); name=in.next(); course=in.next(); student2.setStudent(code,name,course); student1.showStudent(); student2.showStudent(); } }
Prog 17
Prog 18
Prog 19
Prog 20
Prog21
Prog22
Prog 23
Prog 24
Prog 25
Prog 26
Prog 27
Prog 28
Prog 29
Prog 30
Prog31
Prog32
Prog 33
Prog 34
Prog 35
Prog 36
Prog 37
Prog 38
Prog 39
Prog 40
Prog51
Prog52
Prog 53
Prog 54
Prog 55
Prog 56
Prog 57
Prog 58
Prog 59
Prog 60
Prog51
Prog52
Prog 53
Prog 54
Prog 55
Prog 56
Prog 57
Prog 58
Prog 59
Prog 60
Prog61
Prog62
Prog 63
Prog 64
Prog 65
Prog 66
Prog 67
Prog 68
Prog 69
Prog 70
Prog71
Prog72
Prog 73
Prog 74
Prog 75
Prog 76
Prog 77
Prog 78
Prog 79
Prog 80