Java fundamentals

1) 2) 3) 4) write a Java program to print Hello World in console? Write a Java program to input a String and print it in the console? Write a Java program to input an age and check the no is greater than 18 or not? Write a Java program to input three marks and find the grade? if average_mark is above 90 -- s if average_mark is above 80 – a if average_mark is above 70 -- b if average_mark is above 60 -- c if average_mark is above 50 – d if average_mark is below 50 –f 5) Write a program to print even nos, odd numbers and factorials up to 100 6) Write a program to print the sum of first 100 odd nos 7) Write a menu for a menu driven application with do while loop(you can assign the menu options) 8) Convert programs 3 and 4 to repeatedly execute until as and when you want to terminate 9) Write a program to print the factorial up to the given no 10)Write a program to input a no and check its prime or not

Using Arrays
11)Write a program to store all Java keywords into an array and print it? 12)Modify the above program to print all in ascending and descending order? 13)Input a keyword and check that keyword is available in the array or not? 14)Convert all strings into upper case and print it? 15)Store N integers into an array and print a range of nos from the array? 16)Store N integers into an array and print this in ascending and descending order? 17)Write a program to store N strings into an array and print all elements in descending order? 18)Convert all Strings in the above array into descending order? 19)Write a program to input a sentence and slice and store each words into an array and sort this array and print this? 20)Accept N command line arguments and print this? 21)Accept N command line arguments and convert all characters in the array into Toggle Case(capital to small and small into capital) 22)Accept three numbers into command line arguments and print its sum average and product?if no command line arguments are there the program will exit soon 23)Write a program to store N strings into an array and store a subset(from a give range) into a second array and print these two arrays? 24) Write a program to store N students three marks and print sum average and grade , grade you can consider as 4th programs?The result you have to print in Ascending order and descending order? 25)Modify the above program to input a name and print its informations 26)Modify the above program to input a range and store the data into another storage?

Using Double Dimensional arrays
27)Write program to store and display following data 1 12 123 1234 12345 28)write a program to input and n*m Matrix and print its row ways sum and column ways sum 29) write a program to input a N*M matrix and inverse this 30) Write a program to input an N*M matrix and print the diagonal element’s sum? 31) write a program to store some students three marks and print this in ascending and descending order? 32) you have three single dimensional arrays with N size rearrange these data into a double dimentional array Using Switch statement 33) You have an array database as with name,salary and grade. Take you have three category grades (a,b and c) . assume you have N employees. You have to give following salary hike a--30% b—25% c—20% Prepare a report of Hiked salary list 34) you have an Array database with Customername,unit,slab, you have three slabs A,b and c, For A For first 100 units .75 paise For second 200 units Rs 1.25 For for Thirs 200 units Rs 1.50 For Remaining units its Rs 2 For B Twice of A For C Thrice of A

Prepare the Bill for all Slabs of customers 35) An array stores names and average marks assign a grade for all , grade you can set as question number 4 36) make a Menu driven application's menu for an import Export trade , options you can select , main categories are Import, Export ,Travel,Guides online 37)you have an employee database in an array

Print odd ways and even ways records 401Write a menu driven program with following options a. Set limit (setting limit, other options will work up to this) b. Even c. Odd d. Factorial e. Prime f. Exit Enter a choice (a to f) 39) write a menu driven application for adding,deleting,editing,printing and existing from an employee database stored in an Array 40)Convert the above program to call program with a command line argument of even,odd,factorial,prime to print appropriate module

Functions without arguments and return types

Using Functions

41 write a function sum() to print sum of first 100 nos 42 write a function sumEven() to print sum of first 100 even nos //Sum of even numbers up to a limit package org.javabasic; import java.util.Scanner; public class SumEvenFunction { public static void main(String[] args) { SumOfEven(); } static void SumOfEven() { int sum = 0; System.out.print("Enter Even Number Limit : "); Scanner scan = new Scanner(System.in); int limit = scan.nextInt(); int count = 0; for(int i = 1; i <=200; i++) { if((i%2) ==0) { sum = sum + i; count++; if(count == limit) {

}

break;

} }

} } System.out.println("Sum of first " + limit + " even numbers : " + sum);

43 write a function sumOdd() to print the sum of first 100 odd nos //Sum of odd numbers up to a limit package org.javabasic; import java.util.Scanner; public class SumOddFunction { public static void main(String[] args) { OddOfEven(); } static void OddOfEven() { int sum = 0; int count = 0; System.out.print("Enter Odd Number Limit : "); Scanner scan = new Scanner(System.in); int limit = scan.nextInt(); for(int i = 1; i <=200; i++) { if((i%2) !=0) { sum = sum + i; count++; if(count == limit) { break; } continue;

} } System.out.println("\nSum of even numbers : " + sum); } }

44 write function getPrime to print the prime no of first 100 nos 45 write a function getFact() to print the factorial of first 25 nos public class FactorialFunction { public static void main(String[] args) { Factorial(); } static void Factorial() { long fact = 1; for(int i = 1; i < 25; i++) { for(int j = 1; j <= i; j++) { fact = fact * j; } System.out.println("Factorial of " + i + " : " + fact); fact =1; }

} }

46 write the program for input an array and print this in functional ways, you should have input() for inputting array, sortAscending() for sorting array in ascending order,sortDescending() for sorting array in descending order, print function for printing an array 47 you have to store the following informations in to an array(Double Dimontional) Name Email salary input N employees informations and print this. Before printing you need sort this in the ascending order 48 convert the question no 4 into functional notations 49 convert the question no 28 into functional notation 50 convert the question no 29 into functional notation Using functions with arguments 51 convert the 41st program for printing N nos sum import java.util.Scanner; public class SumFnWithArgs { public static void main(String[] args) { System.out.print("Enter the limit : " ); Scanner scan = new Scanner(System.in); int lim = scan.nextInt(); Sum(lim);

} static void Sum(int limit) { int sum = 0; for(int i = 1; i <=limit; i++) { sum = sum + i; } System.out.println("Sum of first " + limit + " number is : " + sum);

} }

52 write the function sumEven() to print the even sum upto a given number package org.functions; import java.util.Scanner; public class SumFnEvenNumArgs { public static void main(String[] args) { System.out.print("Enter Even Number Limit : "); Scanner scan = new Scanner(System.in); int limit = scan.nextInt(); } SumOfEven(limit);

static void SumOfEven(int lim) { int sum = 0; for(int i = 1; i <=lim; i++) { if((i%2) ==0) { sum = sum + i; continue; } } System.out.println("\nSum of even numbers upto " + lim + " : " + sum); } } 53 write the function sumOdd() to print the odd sum upto a given number

package org.functions; import java.util.Scanner; public class SumFnOddNumArgs { public static void main(String[] args) { System.out.print("Enter Odd Number Limit : "); Scanner scan = new Scanner(System.in); int limit = scan.nextInt(); } SumOfEven(limit);

static void SumOfEven(int lim) { int sum = 0; for(int i = 1; i <=lim; i++) { if((i%2) !=0) { sum = sum + i; continue; } } System.out.println("\nSum of odd numbers upto " + lim + " : " + sum); } } 54 write a function getPrime() to print the prime numbers upto a Given number import java.util.Scanner; public class PrimeFnWithArgs { public static void main(String[] args) { System.out.print("Enter The Limit : "); Scanner x=new Scanner(System.in); int n=x.nextInt(); } prime(n);

static void prime(int lim) { long i,j; boolean flag=false; for(i=2;i<lim;i++)

{

for(j=2;j<=i/2;j++) { if((i%j)==0) { flag=true; break; } } if(flag==false) { System.out.println(i); } flag=false;

} }

}

55 write a function getFact to print the factorial up to a given number import java.util.Scanner; public class FactorialFnWithArgs { public static void main(String[] args) { System.out.print("Enter the factorial limit : "); Scanner scan = new Scanner(System.in); int limit = scan.nextInt(); Factorial(limit); } static void Factorial(int limit) { long fact = 1; for(int i = 1; i < limit; i++) { for(int j = 1; j <= i; j++) { fact = fact * j; } System.out.println("Factorial of " + i + " : " + fact); fact =1; } } }

56 write a function to sort and print n numbers import java.util.Scanner; public class SortAndPrint { static int[] arr; public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter the no. of numbers : "); int limit = scan.nextInt(); arr = new int[limit]; for(int i =0; i < limit; i++) { System.out.print("Enter element " + i + " : "); arr[i] = scan.nextInt(); } System.out.print("\nEnter 1 for Asecending Order 2 for Descending Order"); int opt = scan.nextInt(); if(opt == 1) { sortAsec(1); } else { sortDesc(2); } } static void sortAsec(int opt) { int temp; System.out.println("Ascending Order :"); for(int i = 0; i < arr.length; i++) { for(int j = i; j < arr.length; j++) { if(arr[i] > arr[j]) { temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } } } for(int i = 0; i < arr.length; i++)

{ } }

System.out.println(arr[i]);

static void sortDesc(int opt) { int temp; System.out.println("Descending Order :"); for(int i = 0; i < arr.length; i++) { for(int j = i; j < arr.length; j++) { if(arr[i] < arr[j]) { temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } } } for(int i = 0; i < arr.length; i++) { System.out.println(arr[i]); } } } 57 write a function sum(int,int,int)to print the sum import java.util.Scanner; public class AddTwoNumbers { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter two numbes to add : "); int num1 = scan.nextInt(); int num2 = scan.nextInt(); sum(num1, num2); } static void sum(int num1, int num2) { System.out.println("Sum " + num1 + " and " + num2 + " = " + (num1+num2));

} } 58 write a functions average(int,int,int)to get the average import java.util.Scanner; public class AverageFunction { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter three numbers : "); int num1 = scan.nextInt(); int num2 = scan.nextInt(); int num3 = scan.nextInt(); sum(num1, num2, num3); } static void sum(int num1, int num2, int num3) { int avg = (num1 + num2 + num3)/3; System.out.println("Average of " + num1 + " " + num2 + " and " + num3 + " is "+ avg); } } 59 write a function product(int,int,int)toget the product public class ProductFunction { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter three numbers : "); int num1 = scan.nextInt(); int num2 = scan.nextInt(); int num3 = scan.nextInt(); sum(num1, num2, num3); } static void sum(int num1, int num2, int num3) { int prd = num1 * num2 * num3; System.out.println("Product of " + num1 + " " + num2 + " and " + num3 + " is "+ prd); } }

60 write a function square(int) to get the square import java.util.Scanner; public class SquareFunction { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter number whos square is to be finded out : "); int num = scan.nextInt(); sum(num); } static void sum(int num) { System.out.println("Square of " + num + " is : "+ (num*num)); } }

Using functions with arguments and return types
61 write a function as int sum(int,int,int) import java.util.Scanner; public class SumFnReturn { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter three numbers : "); int num1 = scan.nextInt(); int num2 = scan.nextInt(); int num3 = scan.nextInt(); int sum = sum(num1, num2, num3); System.out.println("Sum of " + num1 + " " + num2 + " "+ " and " + num3 + " is : "+ sum); } static int sum(int num1, int num2, int num3) { return (num1 + num2 + num3); }

} 62 write a function as float product(float,float,float) import java.util.Scanner; public class ProductFnInFloat { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter three numbers : "); float num1 = scan.nextFloat(); float num2 = scan.nextFloat(); float num3 = scan.nextFloat(); float prod = product(num1, num2, num3); System.out.println("Product of " + num1 + " " + num2 + " and " + num3 + " is "+ prod); } static float product(float num1, float num2, float num3) { return (num1 * num2 * num3); }

}

63 write a function as long product(int,int,int) import java.util.Scanner; public class LongFnProduct { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter three numbers : "); long num1 = scan.nextLong(); long num2 = scan.nextLong(); long num3 = scan.nextLong(); long prod = product(num1, num2, num3); System.out.println("Product of " + num1 + " " + num2 + " and " + num3 + " is "+ prod); } static long product(long num1, long num2, long num3) { return (num1 * num2 * num3); } } 64 write a function as int square(int)

import java.util.Scanner; public class SquareFnReturn { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter number whos square is to be finded out : "); int num = scan.nextInt(); int square = sqr(num); System.out.println("Square of " + num + " is : "+ square); } static int sqr(int num) { return (num * num); }

}

65 rewrite question number 4 for using function with arguments and return types 66 write a function to get sum of odd nos -int getSumOdd(int) 67 create a function as int getEven(int) 68 write a function as int getLength(String) import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class LengthOfString { public static void main(String[] args) throws IOException { System.out.print("Input a string : "); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int len = getLength(br.readLine()); } System.out.println("Length of string : " + len);

}

static int getLength(String str) { return (str.length()); }

69 write a function as chat getCharAt(String sentence,int loc) import java.io.BufferedReader; import java.io.IOException;

import java.io.InputStreamReader; public class CharAtFunction { public static void main(String[] args) throws IOException { System.out.print("Input a string : "); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str = br.readLine(); System.out.print("Enter location of char :"); int loc = Integer.parseInt(br.readLine()); loc = loc-1; char ch = getCharAt(str, loc); System.out.println("Char at " + loc +"is : " + ch);

}

}

static char getCharAt(String str,int loc) { return (str.charAt(loc)); }

70 write a function as String getStringAt(String sentence,int startPos,int len) import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class GetStringFunction { public static void main(String[] args) throws IOException { System.out.print("Input a string : "); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str = br.readLine(); System.out.print("Enter starting location :"); int loc = Integer.parseInt(br.readLine()); System.out.print("Enter ending location :"); int end = Integer.parseInt(br.readLine()); String getStr = getStringAt(str, loc, end); System.out.print("String Between " + loc +"and " + end + " is : "+ getStr + "\n");

}

}

static String getStringAt(String str,int loc, int end) { return (str.substring(loc, end)); }

71 write a function as String concate(String s1,String s2) import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class StringConcatenation { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Input first string : "); String firstStr = br.readLine(); System.out.print("Input second string : "); String secondStr = br.readLine(); String getStr = concate(firstStr, secondStr); System.out.print("After concatenation : "+ getStr + "\n");

}

}

static String concate(String firstStr, String secondStr) { return (firstStr.concat(secondStr)); }

72 write a function as int positionAt(String mainSentence,int subSentence) import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class StringPosMaintain { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Input first string : "); String firstStr = br.readLine(); System.out.print("Enter char postion "); int pos = Integer.parseInt(br.readLine()); int posPoint = positionAt(firstStr, pos); System.out.print("Code Point At " + pos + " is : "+ posPoint + "\n");

}

static int positionAt(String firstStr, int pos) {

} }

return (firstStr.codePointAt(pos));

73 write a functions as int charAt(String main,char c) import import import import java.io.BufferedReader; java.io.IOException; java.io.InputStreamReader; java.util.Scanner;

public class CharAt { public static void main(String[] args) throws IOException { Scanner scan = new Scanner(System.in); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Input first string : "); String firstStr = br.readLine(); System.out.print("Enter char whose location to be finded out "); char ch1 = (char)System.in.read(); int posPoint = positionAt(firstStr, ch1); System.out.print("Code Point At " + ch1 + " is : "+ posPoint + "\n");

}

static int positionAt(String firstStr, char ch) { int len = firstStr.length(); int pos = 0; for(int i = 0; i < len; i++) { if(firstStr.charAt(i)==ch) { pos = i; } } return pos; } } 74 write a function as int insertAt(String inString,String newString,int loc) import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; public class InsertAt { public static void main(String[] args) throws IOException {

Scanner scan = new Scanner(System.in); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Input first string : "); String firstStr = br.readLine(); System.out.print("Input second string : "); String secondStr = br.readLine(); System.out.print("Location in 1st to add 2nd string "); int loc = scan.nextInt(); StringBuffer posPoint = positionAt(firstStr, secondStr, loc); System.out.print("Completed String : "+ posPoint + "\n");

}

}

static StringBuffer positionAt(String firstStr, String secondStr, int loc) { StringBuffer sb = new StringBuffer(firstStr); sb.insert(loc, secondStr); return sb; }

75 write a function as boolean avilaAt(String mainString,String subString) import import import import java.io.BufferedReader; java.io.IOException; java.io.InputStreamReader; java.util.Scanner;

public class StringSearch { public static void main(String[] args) throws IOException { Scanner scan = new Scanner(System.in); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Input first string : "); String firstStr = br.readLine(); System.out.print("Input part of string to be finded out : "); String secondStr = br.readLine(); boolean posPoint = positionAt(firstStr, secondStr); System.out.print("Completed String : "+ posPoint + "\n"); } static boolean positionAt(String firstStr, String secondStr) { int index = 0; index = firstStr.indexOf(secondStr); if(index < 0) return false;

else return true;

} } functions with Arrays 76 create a function named sort to get an array in sorted array import java.util.Scanner; public class SortingArrayFunction { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter No. Of Elements : "); int lim = scan.nextInt(); int[] arr = new int[lim]; int[] sorted = new int[lim]; System.out.println("Enter " + lim + " array elements :"); for(int i =0; i <lim; i++) { arr[i] = scan.nextInt(); } sorted = sortArray(arr); System.out.println("Number in Ascending order "); for(int i =0; i <lim; i++) { System.out.println(sorted[i]); } } static int[] sortArray(int[] arr) { for(int i =0; i <arr.length; i++) { for(int j = 0; j < i; j++) { if((arr[i] < arr[j])) { int temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } } } return arr;

} } 77 create a function as to get subset of an integer array-int[] getSubset(int[],int min,int max) import java.util.Scanner; public class SubSetOfArray { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter No. Of Elements : "); int lim = scan.nextInt(); int[] arr = new int[lim]; int[] sorted = new int[lim]; System.out.println("Enter " + lim + " array elements :"); for(int i =0; i <lim; i++) { arr[i] = scan.nextInt(); } System.out.print("Enter min index : "); int min = scan.nextInt(); System.out.print("Enter max index : "); int max = scan.nextInt(); //sorted = subSetSoft(arr, min, max); sorted = subSetHard(arr, min, max); System.out.println("Number in Ascending order "); for(int i =0; i <=(max-min); i++) { System.out.println(sorted[i]); } } static int[] subSetSoft(int[] arr, int min, int max) { int k =0; int[] subSet = new int[arr.length]; for(int i = min; i <max; i++) { subSet[k] = arr[i]; k++; } return subSet; } static { int int int int[] subSetHard(int[] arr, int min, int max) k =0; beg =0; exit = 0;

int[] subSet = new int[arr.length]; for(int i = 0; i < arr.length; i++) { if(arr[i] == min) beg = i; else if(arr[i] == max) exit = i; } for(int i = beg; i <= exit; i++) { subSet[k] = arr[i]; k++; } } } 78 create a function to get the sum of an integer array-int sumArray(int[]) import java.util.Scanner; public class SumOfIntegerArray { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter the limit : "); int lim = scan.nextInt(); int arr[] = new int[lim]; System.out.println("Enter Elements : "); for(int i = 0; i < lim; i++) { arr[i] = scan.nextInt(); } int arrSum = getArraySum(arr); System.out.println("Sum of array : " + arrSum); } static int getArraySum(int[] arr) { int sum = 0; for(int i = 0; i < arr.length; i++) { sum = sum + arr[i]; } return sum; return subSet;

}

}

79 create a function to get the presence of a number from an integer array-boolean presentNumber(int[] source,int noToFound) import java.util.Scanner; public class PresentNumber { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter the limit : "); int lim = scan.nextInt(); int arr[] = new int[lim]; System.out.println("Enter Elements : "); for(int i = 0; i < lim; i++) { arr[i] = scan.nextInt(); } System.out.println("Enter Num to find : "); int numToFind = scan.nextInt(); boolean status = presentNumber(arr, numToFind); System.out.println("Status of value you entered : " + status);

}

static boolean presentNumber(int arr[], int numToFind) { boolean value = false; for(int i = 0; i <arr.length; i++) { if(arr[i] == numToFind) { value = true; break; } else { value = false; } } if(value == true) return true; else return false; } }

80 create a function to fill all values in an array into a given value-boolean fill(int[] sorceArray,int valueToFill) 81 write a function showArray(int[] sourceArray)to print all elements in this array public class ShowArray { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter the limit : "); int lim = scan.nextInt(); int arr[] = new int[lim]; System.out.println("Enter Elements : "); for(int i = 0; i < lim; i++) { arr[i] = scan.nextInt(); } System.out.print("The array elements are : \n"); showArray(arr);

}

static void showArray(int[] arr) { for(int i = 0; i <arr.length; i++) { System.out.println(arr[i]); } } } 82 write a function to accept a double dimension array and print this import java.util.Scanner; public class DoubleDimPrint { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter the size of matrix : "); int m = scan.nextInt(); int n = scan.nextInt(); int arr[][] = new int[m][n]; System.out.println("Enter Elements : "); for(int i = 0; i < m; i++) { for(int j = 0; j < n; j++) {

}

arr[i][j] = scan.nextInt(); } System.out.println("Enter Elements : ");

}

System.out.print("The array elements are : \n"); showArray(arr);

static void showArray(int[][] arr) { for(int i = 0; i <arr.length; i++) { for(int j = 0; j < arr[i].length; j++) { System.out.print(arr[i][j]); } System.out.println(); } } } 83 write a function to accept a double dimension array and return its row ways sum- int rowsum[] getRowSum(int[][]sourceDoubleDimensionArray) import java.util.Scanner; public class DoubleDimRowSum { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter the size of matrix : "); int m = scan.nextInt(); int n = scan.nextInt(); int arr[][] = new int[m][n]; System.out.println("Enter Elements : "); for(int i = 0; i < m; i++) { for(int j = 0; j < n; j++) { arr[i][j] = scan.nextInt(); } System.out.println("Enter Elements : "); } System.out.print("The array elements are : \n"); int[] rowSum = showArray(arr); for(int i = 0; i <rowSum.length; i++) { System.out.println("Sum of row [" + i +"] : " + rowSum[i]); }

} static int[] showArray(int[][] arr) { int sum = 0; int[] rowSum = new int[arr.length]; for(int i = 0; i <arr.length; i++) { for(int j = 0; j < arr[i].length; j++) { sum = sum + arr[i][j]; } rowSum[i] = sum; sum = 0; } return rowSum; }

}

84 write a function to get the column ways sum of a Double dimensional array-int[] colSum getColumnSum(int[][]sourceArray) import java.util.Scanner; public class DoubleDimColSum { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter the size of matrix : "); int m = scan.nextInt(); int n = scan.nextInt(); int arr[][] = new int[m][n]; System.out.println("Enter Elements : "); for(int i = 0; i < m; i++) { for(int j = 0; j < n; j++) { arr[i][j] = scan.nextInt(); } System.out.println("Enter Elements : "); } System.out.print("The array elements are : \n"); int[] colSum = showArray(arr); for(int i = 0; i <colSum.length; i++) { System.out.println("Sum of col [" + i +"] : " + colSum[i]); } } static int[] showArray(int[][] arr)

{

int[] colSum = new int[arr.length]; for(int i = 0; i <arr.length; i++) { for(int j =0; j <arr[i].length; j++) { colSum[j] = colSum[j] + arr[i][j]; } } return colSum;

}

}

85 write a function to get the diagonal elements sum of a two dimensional array-int getDiagonalSum(int[][]sourceArray) import java.util.Scanner; public class DoubleDimDiagonalSum { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter the size of matrix : "); int m = scan.nextInt(); int n = scan.nextInt(); int arr[][] = new int[m][n]; System.out.println("Enter Elements : "); for(int i = 0; i < m; i++) { for(int j = 0; j < n; j++) { arr[i][j] = scan.nextInt(); } System.out.println("Enter Elements : "); } System.out.print("The array elements are : \n"); int diagSum = diagonalSum(arr); System.out.println("Sum of diagonal elements" + diagSum);

}

private static int diagonalSum(int[][] arr) { int diagSum = 0; for(int i = 0; i < arr.length; i++) { for(int j = 0; j <arr[i].length; j++) { if(i == j) {

}

diagSum = diagSum + arr[i][j];

} }

} } return diagSum;

86 write a function to check whether a string is available in a double dimonsional array –boolean stringAvail(String[][] sourceArray) import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class DoubleDimStringSearch { public static void main(String[] args) throws IOException { BufferedReader scan = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter the size of matrix : "); int m = Integer.parseInt(scan.readLine()); int n = Integer.parseInt(scan.readLine()); String arr[][] = new String[m][n]; System.out.println("Enter Elements : "); for(int i = 0; i < m; i++) { for(int j = 0; j < n; j++) { arr[i][j] = scan.readLine(); } System.out.println("Enter Elements : "); } System.out.print("The array elements are : \n"); boolean status = stringSearch(arr); System.out.println("String status in array : " + status);

}

private static boolean stringSearch(String[][] arr) { // System.out.print("The array elements are : \n"); boolean status = false; String str = "hello"; for(int i = 0; i < arr.length; i++) { for(int j = 0; j <arr[i].length; j++) { System.out.print(arr[i][j]); if(arr[i][j].compareTo(str) == 0)

{

} } System.out.println(); } return status; } }

status = true; break;

87 write a function to concat a single dimonsional array into a String –String getString(int[][]sourceArray) 88 write a program to store the information of N students name and six subjects marks into an arraydatabase and print the total mark and average mark, (your main function should have only function calling) import java.util.Scanner; public class StudentInfo { public static void main(String[] args) { getStudentInfo(); } private static void getStudentInfo() { Scanner scan = new Scanner(System.in); System.out.print("Enter the no. of students : "); int student = scan.nextInt(); double[][] marks = new double[student][6]; for(int i = 0; i <student; i++) { for(int j = 0; j < marks[i].length; j++) { System.out.print("Enter mark [" + j + "] : "); marks[i][j] = scan.nextDouble(); } System.out.println(); } //sum print double sum = 0, avg = 0; for(int i = 0; i <student; i++) { for(int j = 0; j < marks[i].length; j++) { sum = sum + marks[i][j]; } avg = sum/6;

System.out.println("Total mark of student [" + i +"]: " + sum + "and average : " + avg); sum =0; } } 89 suppose you have a large String make a function to return all words in this string as an array—String[] getArry(String sourceSentence) public class StringAsChar { public static void main(String[] args) { String sent = "suppose you have a large String make a function to return all words in this string"; String[] words = getStringAsChar(sent); for (String word : words) { System.out.println(word); } }

}

static String[] getStringAsChar(String str) { String[] words = str.split(" "); return words; } } 90 write a program to convert all charactes in a String into a character arraay-char[] getCharacterArray(String sourceSentence) public class StringAsChars { public static void main(String[] args) { String sent = "suppose you have a large String make a function to return all words in this string"; char[] words = getStringAsChar(sent); for (char word : words) { System.out.println(word); }

}

static char[] getStringAsChar(String str) { char[] words = str.toCharArray(); return words; } }

91 write a function to convert all characters in a string into a byte array-byte[] getByteArray(String sourceSentence) public class StringAsByteArray { public static void main(String[] args) { String sent = "suppose you have a large String make a function to return all words in this string"; byte[] words = getStringAsChar(sent); for (byte word : words) { System.out.println(word); } } static byte[] getStringAsChar(String str) { byte[] words = str.getBytes(); return words; }

}

92 write a function to fill all Strings in a single dimension Array into a null value, and call this method for filling all rows in a String array. public class FillNull { public static void main(String[] args) { String[] sent = {"a", "b", "c", "fellow"}; String[] words = fillAsNull(sent); for (String word : words) { System.out.println(word); }

}

}

static String[] fillAsNull(String[] str) { for(int i = 0; i < str.length; i++) { str[i] = null; } return str; }

93 Write a function to sort a single dimension Array – int[] sort(int[],boolean type), if true –ascending , if false Descending 94 Write a function to convert all Strings into given case-String[] convert(String[],boolean type) if true – upper case if false –lower case 95 Write a function to set a particular String in an array as given String- boolean setString(String[] source,String toSet,int index) 96 Make the above functions integer version too 97 Write a function to returns the ascii value of a to z public class AsciiAlphabet { public static void main(String[] args) { System.out.println("The Ascii value of alphabets "); int[] output = getAscii(); for(int i = 0; i <=25; i++) { System.out.println(output[i]); }

}

}

static int[] getAscii() { int[] out = new int[26]; int k = 0; for(char i ='a'; i <= 'z'; i++) { out[k] = (int)i; k++; } return out; }

98 Suppose you have an array of sentences, make a function as follows, boolean[]present getAvailability(String[] sourceArray,String[] words) sourceArray—is a String array of sentences Words-is a words array for 1 to 1 checking , if this word is vailable in that array the return array’s element is true else false 99 Write a a function for binary search of an array 100Write a function of bubble sort of an array Using classes(you should set all member varibles private if inheritance necessary set it as protected,no member variables should be public in any class)

101 Create a Person class with following attributes
Name height color 102 Make your own Person Object

103 Imagine you have a three persons 104 How you would write a message Person initialized when each object initialization 105 How you would check two Person objects are similar or not 106 How you would define a function as follows
boolean checkEquals(person p1,Person p2)

107 How you would make a batch of N persons and print this 108 How you would copy the above N Persons with a new Person 109 How would you set a person object null in the above N persons 110 Print all persons color only 111 Make an address class with following attributes
houseName phoneNo emailAddress mobileNo

you should have all functions to seperately set and get all attributes you should have all constructors for setting each and all attributes you should have methods for inputting all data through keyboard 112 How you would make a program to print N persons details with Address by usinh Person class and Address class . your programm would print following report of N records Name Height HouseName Phone No Emailaddress Mobile hint –Has a relation How would make a program to set each persons have three addresses report should be as follows Name color Height Addess1Email 1Phone 1mobile 1Addess2Email 2Phone 2mobile 2 and so on

113 Write a program to input N persons and Three addresses . Further you would input a person name
and print his name and all addresses

114 Write a function as follows

Address[] getAddress(Person p) Person P is the Person object to return address Address[] is the address array of corresponding Person 115 Check re many Persons have no Address hint Any of the Address object is null Person has no such address object 116 Input a Person name and set its address into null 117 Write a menu driven application with following options 1)Add a Person 2)Delete a Persson

3)Edit a Person 4)ShowAll 5)Add Address 6)Exit 118 Create a menu driven searching application from a person database with the options of email search,name search, phone no search and exit 119 How you make an application for adding N address for a person and print it 120 How you would sort the previous program 121Create a class name Customer with following attributes a. customerName b. customerCode c. customerAge d. customerLocation e. Address customerAddress f. accountNo g. set default constructors and other six constructors for setting each member variables h. make six set of setter getter methods i. 122 Create these classes SavingsAccount,FixedAccount,CurrentAccount,RecurringAccount. Write a programm to add these services to a customer 123 Write a menu driven program for adding the above services to customers 124 Create an array database of N customers and make a serach function for searching a particular customer object 125 Sort the above array database in descending order Using inheritance

126 Create a class Number with following attributes
minValue maxValue public void getIntegerNumbers()//print integers from min to max. 127 Create a new class(sub class of Number) for getting oddNo and even nos 128 Create prime nos from the Number class previously defined 129 Create a class Student with Personal details 130 Create a subclass of (sub class of previously defined Student) name FirstExam of three subjects marks 131Create a new subclass from FirstExam for printing the Report of each students Progress Report, class name is ProgressReport Student Exams ProgressReport 132How you willl resuse the class while at Second term exam 133Create an Employee class with empName,empID,email,phoneNo and appropriate member functions 134Add some Managerial Persons with some Managerial functions 135Add some Accounts employees with accounts options 136Add some technical employees with some technology related functions Employee ManagerialProffessional Employee Accounts Employee Technical 137 How would you make a Java Form with inheritance 138 Make the following relation Building is a Home has a Toilet 139 Create a class ProgressList with Six subjects marks

140 Reuse this ProgressList for 12 months Progress of a batch of students
using dynamic polimorphism

141 How would you make PrintClass for printing all these objects 142 How would you make a print function for print any of the following object
shape Rectangle Triangle Ovel polygon Circle ( your print function alone cab print all these objects)

143 Suppose you have following hierachy

Employee management Manager Employee Technical CTO Employee Accounts CFO write an Input and print function for printing all Objects 144Write the following class hierarchy User Admin User Gardenuser User SystemUser User Limiteduser make a getUser for getting any of these users

145 Make a class hierarchy as follows

Number Prime Even Odd factorial fibonoscii make a polymorphic show function to print all Number,prime,even,odd,factorial and fibonoscii numbers

146 Make a console based get() to returns any type of prmitive data that is int,float,boolean and all
Input i=new Number(); i.get() //deliver an int value i=new FloatNumber(); i.get()//will deliver float value and so on 147How would you make your own print function to print all your type of data including primitiver,arrays,objects and so on 148 Make a print() function to print all types of arrays in console 149 Make a print() function to print all wrapper types in console 150 Make a print() to print all your objects in console Using interfaces

151 Make an interface with following methods
void void void void void getPrime(); getFactorial(); hetEven(); getFibonoscii(); getOdd();

152 Override these methods to get all numberes in the Number class 153 Suppose you have Customer,SavingsAccount,CurrentAccount ,Fixed and RecurringAccount classes
make class hierarchy as follows interface for add,delete,update,print this is derived a sub class for each accounts methods make a programm for input some account holders and print this

154 Create an interface Vehicle with start(),run() and brake(), override these methods for making your
car,bus,train objects

155Write a program to modify the 151st program to override only a partial methods(Adapter classes)
using packages

156 Create a package Bank to store Customer,SavingsAccount,FixedDeposit,RecurringDeposit and
CurrentAccount.

157 Write a program to import Bank package and make a Menu driver Banking application for Adding
customers,deleting customers and providing all banking services for them

158 Create a package restricted class for storing some classes 159 Create a public package for storing some utility classes 160 How would you import a only static methods from a class, explain it with an example
Using File Streams(java.io)

161 Write a program to make a java File object and make this in the file systsem 162 Write a program to make an avilable file Object and delete this 163 Write a programm to display all files in a specific folder, the folder you can specify as command line
argument 164 Write a programm to display .html files in a specific folder, the folder you can specify as command line argument 165 Write a program to delete all .html files in a specific folder 166 Write a program to print the properties of a text file 167Write a program to check whether a File object id di rectory or file 168 Write a program for using FileFilter and FileNameFilter\ 169 Write a program to open a textfile and print this in the console 170 Write a program to read date from a text file and convert this in the format for byte stream and print this is the console 171Write a program to read text file and store this in a character array and print this 172 Write a program to read a text file in String format(using String type reading) 173 Write a a program to read a large chunk of data from text file with Buffering(java.io.BufferedReader) 174 Write a program to input some text and save this in a text file 175 Write a program to save a large block of data in to a file 176 Write a java program to make a stream from a byte array 177 Write a program to get data from two file streams and save this(java.io.SequentialInputStream)

178 Write a program to print the Line numbers of a file 179 Write a program to put line numbers for a file
180Write a java program to count all characters from a text file 181Write a java program to open text file and read the first half of the file three times 182

183

Using AWT

184 Write a program to display a Java window(using java.awt.Frame) 185 Write a program to display first hundred odd numbers in to the Form 186 Write a program to display the java form full screen mode 187 Write a program to add OK Cancel button in the screen 188 Write a program to add an OK and Cancel Button with a TextField, display button caption on the
Textfield when you click on the Buttons 189 Make a java and window, when you click on the close button the console will prompt program will exit or not 190 Make a java window and put a set of CheckBoxes and RadioButtons, with a TextArea, when you click on the Checkboxes and radiobutton the TextArea will appends the caption of the controlls 191 Make a java program with a prgressbar and slider controll, when you move the slider controll progress bar will fill according to the value of the slider 192Write a program to display three slider controll for Red Green and Blue , and make a textfield , use this RGB controlls for filling RGB colors in TextField 193 Write a java programm to play an audio clip 194 Write a java window with a Button, when you click on the Button that will popup a new window, you need to close the window when you click the close button 195Write a java window for sequentially adding some Buttons 196Write a java window to add four buttons in separate areas(use setBounds()) 197 Write a java window with Ok and cancel Button , when you click on the Buttons that will display separate dialog boxes 198 Write a java window with three buttons , first button will open the File open dialog, Button two will display the File save dialog and Button three will display the color chooser dialog 199 Make a java window with a MenuBar and a menu . Stretch the window with a TextArea with some text. Your menu should have , font size, font type, font color setting options for the TextARea 200 Write a java window with a canvas(java.awt.Canvas)to show some text 201 Write a window with an 20 TextField in row ways order 202 Write a java window that display a set of Buttons at Top, a set TectFields at bottom, a set of check boxes at left side and set of Radio buttons at right side(java.awt.BorderLayout) 203 Write an Applet to display the HelloWorld message 204 Make a java window that will displays three tabs, first tab will display some Buttons, secomd tab will display some TextAream, next Tab will display a TextArea, make sure that only one tab will display at a time(java.awt.cardLayout) 205 Write a java program for displaying a java window with Menu having some Checkbox menu items(java.awt.CheckBoxmenuItem) 206 Write a java program to display a Choice box with some items, when you choose each items the form will display the selected choice 207 Write a program to display a java window that will display some Image buttons(java.awt.Image and java\.awt.button) 208 Write a java window that will display a Popup window while you right click

209 Write a java window that having a horizontal and vertical scroll bar when you click on each scroll bar
that will dislay separate message on a textfield 210 Write a simple java program to display three buttons and a Toolbar(java.awt.Toolbar) 211 Write a GUI for making Customer informations In an array, 212 Write a GUI program for a ProgressReport generator,you can use the same that you used previously 213 Write a java window for inputtig three marks and display its sum and average marks 214 Create a java window for storing comtacts, the data you can store in an and print this, when the user asks for data 215 Write a calculator application 216Write a java window with read button, when you click on the read button that will open FileDialog and display the selected file in the TextArea 217 Write a java window to open,edit and save a Text file 218Write a java editor for formatting a text in the textfield 219Write a java window that will open two text fields and save this into a new file 220Write a java window that will close the window with WindowAdapter class 221Write a java window with some textfields and set its focus with WindowFocus listener 222Write java window to open a selected folders files and select a file and delete this 223Write a java window to popup some other wiindows and the programm will terminate only after close the main window 224

Sign up to vote on this title
UsefulNot useful