Posts

SQL Lab1: Create a Database Table for DayCare

1: Create a Database Table for DayCare sol :         CREATE TABLE dc_kids ( kid_id INT NOT NULL AUTO_INCREMENT, kid_fname VARCHAR(30) NOT NULL,         kid_lname VARCHAR(30) NOT NULL, kid_gender CHAR(1) NOT NULL,         kid_age SMALLINT UNSIGNED NOT NULL,         kid_address TEXT NOT NULL, kid_dob DATETIME NOT NULL,         kid_father VARCHAR(30) NOT NULL,         kid_mother VARCHAR(30) NOT NULL, kid_emgcontact VARCHAR(15) NOT NULL, PRIMARY KEY (kid_id)  )  ENGINE=INNODB; // Inserting data to Table... INSERT INTO dc_kids (kid_fname, kid_lname, kid_gender, kid_age, kid_address, kid_dob, kid_father, kid_mother, kid_emgcontact) VALUES ('Deep', 'Bhati', 'M', '3', '21st Jump Street', '1996-12-06 05:18:01', 'Mahesh', 'Megha', '987654321'),     ('Scarlett', 'Johansson', 'F', '4', '21B Baker Street', '1992-11-06 06:19:02', 'Bruce', &#

5th sem OOPJ Create a class called Student. Write a student manager program to manipulate the student information from files by using DataInputStream and DataOutputStream.

import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; /**  *  * @author Yash  */ public class pra13 {     public static void main(String arg[]) throws FileNotFoundException, IOException{         DataInputStream din = new DataInputStream(new FileInputStream("new.txt"));         DataOutputStream dout = new DataOutputStream(new FileOutputStream("output1.txt"));                 String str;                 while((str=din.readLine()) != null){         String s2 = str.toUpperCase();         dout.writeBytes(s2 + "\n");         }         din.close();         dout.close();     } }

5th sem OOPJ Create a class called Student. Write a student manager program to manipulate the student information from files by using BufferedReader and BufferedWriter.

import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; /**  *  * @author Yash  */ public class pra12 {     public static void main(String arg[]) throws FileNotFoundException, IOException{         BufferedReader br = new BufferedReader(new FileReader("new.txt"));         BufferedWriter bw = new BufferedWriter(new FileWriter("output.txt"));                 int i;         do{             i=br.read();             if(i != -1){                 if(Character.isUpperCase((char)i)){                 bw.write(Character.toLowerCase((char)i));                 }else{                     bw.write((char)i);                 }             }         }while(i != -1);         br.close();         bw.close();                 } }

5th sem OOPJ Create a class called Student. Write a student manager program to manipulate the student information from files by using FileInputStream and FileOutputStream

import java.io.FileInputStream; import java.io.FileOutputStream; /**  *  * @author Yash  */ public class pra11 {     public static void main(String arg[])throws Exception{         FileOutputStream fout = new FileOutputStream("new.txt"); //new.txt shold be on same directory of the java program file.         String s1 = "\n Student's name : Mr. abc\n Branch : Computer Engineering\n Sem : 5th\n Batch : H";         byte b[] = s1.getBytes();         fout.write(b);                 FileInputStream fin = new FileInputStream("new.txt");         int i = 0;         while((i=fin.read()) != -1){             System.out.print((char)i);         }         fin.close();     } }

5th sem OOPJ Write an interactive program to print a diamond shape. For example, if user enters the number 3, the diamond will be as follows:

import java.util.Scanner; /**  *  * @author Yash  */ public class pra10 {     public static void main(String arg[]){         int i,j,k,n;         Scanner sc = new Scanner(System.in);         System.out.print("Enter the Range :");         n=sc.nextInt();         for(i=1;i<=n;i++){             for(j=n;j>=i;j--){                 System.out.print(" ");             }             for(k=1;k<=i;k++){                 System.out.print(" *");             }             System.out.println(" ");         }         for(i=1;i<=n;i++){             for(j=0;j<=i;j++){                 System.out.print(" ");             }             for(k=n;k>i;k--){                 System.out.print(" *");             }             System.out.println(" ");         }     } }

5th sem OOPJ Write an interactive program to print a string entered in a pyramid form. For instance, the string “stream” has to be displayed as follows.

import java.util.Scanner; /**  *  * @author Yash  */ public class pra9 {     public static void main(String arg[]){         char c;         int i,j,k;         Scanner sc = new Scanner(System.in);         String s1;         System.out.print("Enter the String :");         s1=sc.next();         for(i=0;i<s1.length();i++){             for(j=0;j<=s1.length()-i;j++){                 System.out.print(" ");             }             for(k=0;k<=i;k++){                 c = s1.charAt(k);                 System.out.print(c+" ");             }             System.out.println(" ");         }     } }

5th sem OOPJ Create a class which asks the user to enter a sentence, and it should display count of each vowel type in the sentence. The program should continue till user enters a word “quit”. Display the total count of each vowel for all sentences.

import java.util.*; /**  *  * @author Yash  */ public class pra8 { public static void main(String arg[]){         String s1 = new String();                 while(!s1.equals("quit")){         char ch;         int vol=0,cont=0;         System.out.println("Enter the String..");         Scanner sc = new Scanner(System.in);         s1 = sc.nextLine();         StringBuffer sb = new StringBuffer(s1);         for(int i=0;i<sb.length();i++){             ch = sb.charAt(i);             if( ch=='a' || ch=='A' || ch=='e' || ch=='E' || ch=='i' || ch=='I' || ch=='o' || ch=='O' || ch=='u' || ch=='U'){                 vol++;             }else{                 cont++;             }         }         System.out.println("voweles : "+vol);         System.out.println("Consonants :" +cont);         }     }   }