Posts

Prime Adam Program

  package Class12 ; import java.util.Scanner ; public class primeAdam { boolean prime ( int n){ int counter = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { if (n % i == 0) { counter ++; } } if ( counter == 2) return true ; else return false ; } int reverse ( int n){ String t = Integer . toString (n) ; String rev = "" ; for ( int i = t . length () - 1 ; i >= 0 ; i -- ) { rev += t . charAt ( i ) ; } return Integer . parseInt ( rev ) ; } boolean checkAdam ( int n){ int sq = n * n ; boolean flag ; int temp = reverse (n) ; temp = temp * temp ; if ( reverse ( sq ) == temp ) return true ; else return false ; } public static void main ( String [] args) { primeAdam pr = new primeAdam () ; Scanner in = new Scanner ( System . in) ; System . out . ...

Course Management System

  import java.util.InputMismatchException ; import java.util.Scanner ; // Author : Abhinav public class CourseSystem extends Log { public static void main ( String [] args) { CourseSystem ob = new CourseSystem () ; Scanner in = new Scanner ( System . in) ; ob . logging () ; } } class Admin_Feature { Scanner in = new Scanner ( System . in) ; void add_student (){ System . out . println ( "Enter name of Student" ) ; String name_student = in . nextLine () ; System . out . println ( "Enter Roll No of Student" ) ; long roll_no = in . nextLong () ; } void add_Course (){ System . out . println ( "Enter name of Course" ) ; String name_student = in . nextLine () ; System . out . println ( "Enter Teacher Name" ) ; String name_teacher = in . next () ; } } class Student_Feature { } class Course_Management { } class Student_Information { String...

Calculation using symbol (Problem_10)

  package School ; import java.util.Scanner ; public class Problem_10 { public static void main ( String [] args ) { Scanner in = new Scanner ( System . in ); int a []= new int [ 4 ]; String b []= new String [ 3 ]; int output = 0 ; int count = 0 ; int checker = 0 ; // used for capturing index System . out . println ( "Enter element " ); for ( int i = 0 ; i < 4 ; i ++){ a [ i ]= in . nextInt (); } System . out . println ( "Enter Symbol" ); for ( int i = 0 ; i < 3 ; i ++){ b [ i ]= in . next (); } for ( int i = 0 ; i < 3 ; i ++){ switch ( b [ i ]){ case "+" : if ( output == 0 ){ output += a [ i ]+ a [ i + 1 ]; checker = 2 ; } else { output += a [ checker...

Enter Name and Sort it (Problem_8) Form School

  package School ; import java.util.Scanner ; public class Problem_8 { public static void main ( String [] args ) { String Data [] =new String [ 20 ]; Scanner in =new Scanner ( System . in ); System . out . println ( "Enter number of names you want to enter: " ); int input = in . nextInt (); if ( input >= 3 && input <= 20 ) { String temp ; System . out . println ( "Enter name" ); for ( int i = 0 ; i < input ; i ++ ) { Data [ i ] = in . next (); } for ( int i = 0 ; i < input ; i ++ ){ for ( int j = 0 ; j < ( input - 1 ); j ++ ) { if ( Data [ j ]. compareToIgnoreCase ( Data [ j + 1 ]) > 0 ) { temp = Data [ j ]; Data [ j ] = Data [ j + 1 ]; Data [ j + 1 ] = temp ; ...

Reverse each word in sentence without changing position of word (Program_7 by School)

  package School ; import java.util.Scanner ; import java.util.StringTokenizer ; public class Program_7 { public static void main ( String [] args ) { Scanner in = new Scanner ( System . in ); System . out . println ( "Enter Sentence" ); String sentence = in . nextLine (); sentence = sentence . toUpperCase (); String store = "" ; if ( sentence . endsWith ( "." ) || sentence . endsWith ( "!" ) || sentence . endsWith ( "?" )){ sentence = sentence . substring ( 0 , sentence . length () - 1 ); StringTokenizer st = new StringTokenizer ( sentence ); while ( st . hasMoreTokens ()){ store = st . nextToken (); for ( int i = store . length () - 1 ; i >= 0 ; i -- ){ System . out . print ( store . charAt ( i )); } System . out . print ( " " ); } ...

Display and count word which starting and ending with vowel (Problem_6) School

 package School; import java.util.*; class Program_6 {     public static void main(String args[]) {         Scanner in = new Scanner(System.in);         System.out.println("Enter Sentence");         String sentence = in.nextLine();         sentence = sentence.toUpperCase();         String check[] = new String[5];         check[0] = "A";         check[1] = "E";         check[2] = "I";         check[3] = "O";         check[4] = "U";         String Temp = "";         int c = 0;         if (sentence.endsWith(".") || sentence.endsWith("!") || sentence.endsWith("?")) {             sentence = sentence.substring(0, sentence.length() - 1);             StringTokenizer...

Display each word with no of letter in it (Program 4) by School

  import java.util. * ; public class Program_4 { public static void main ( String [] args ) { Scanner in = new Scanner ( System . in ); System . out . println ( "Enter Sentence which end with ? . !" ); String sentence = in . nextLine (); if ( sentence . endsWith ( "." ) || sentence . endsWith ( "!" ) || sentence . endsWith ( "?" )) { sentence = sentence . substring ( 0 , sentence . length () - 1 ); StringTokenizer st = new StringTokenizer ( sentence ); int length = 0 ; String word = "" ; while ( st . hasMoreTokens ()) { word = st . nextToken (); length = word . length (); System . out . println ( word + "\t" + length ); } } else { System . out . println ( "Invalid Input" ); } } }