Skip to main content

Posts

Showing posts from April, 2020

Write a Java program to accept the empno from user and update the salary of employee and display the updated record on the screen. Employee having fields empno, ename & salary.

Write a Java program to accept the empno from user and update the salary of employee and display the updated record on the screen. Employee having fields empno, ename & salary. Program: import java.sql.*; import java.io.*; class Employee { public static void main(String args[]) { Connection con; Statement stmt; ResultSet rs; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:employeeDSN"); stmt = con.createStatement(); System.out.println("Enter Employee No:"); int empno = Integer.parseInt(br.readLine()); System.out.println("Enter new Salary of Employee:"); int salary = Integer.parseInt(br.readLine()); stmt.executeUpdate("update employee set salary = "+salary+" wh

Write a program to implement cat command of UNIX on DOS.

Write a program to implement cat command of UNIX on DOS. cat <filename> to display files on the screen. cat < filename it is same as type command. cat > filename it is same as copy command. Program: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <dirent.h> void main(){ setbuf(stdout,NULL); DIR *dir; struct dirent *ent; FILE *fp; char s[80],temp[80],c[5],f[50],a[2],p[2]; while(1){ printf("\nAP:>"); gets(s); if(strcmp(s,"exit")==0){ exit(0); } sscanf(s,"%s%s%s%s",c,a,f,p); printf("%s|%s|%s|%s",c,a,f,p); if(strcmp(c,"cat")!=0){ printf("invalid command"); }else if(strcmp(a,"<")==0 && strcmp(p,">")==0){ if((dir=opendir(f))==NULL){ perror("Unable to open direcotry."); exit(0); } while((ent= readdir(dir))!=NULL){ printf("%s\n",ent->d_name); } if(closedi

Write a Java program to accept details of Doctor(dno, dname, salary) from the user and insert it into the database(Use PreparedStatement class and AWT).

Write a Java program to accept details of Doctor(dno, dname, salary) from the user and insert it into the database(Use PreparedStatement class and AWT). Program: import java.io.*; import java.sql.*; import java.awt.*; import java.awt.event.*; import javax.swing.JOptionPane; public class Doctor extends Frame implements ActionListener { Label labelDNo, labelDName, labelSalary; TextField textDNo, textDName, textSalary; Button btnAdd; btnExit; public Doctor() { labelDNo = new Label("Doctor No:"); labelDName = new Label("Doctor Name:"); labelSalary = new Label("Doctor Salary:"); textDNo = new TextField(20); textDName = new TextField(20); textSalary = new TextField(20); btnAdd = new Button("Add"); btnExit = new Button("Exit"); setLayout(new GridLayout(4,2)); add(labelDNo); add(textDNo); add(labelDName); add(textDN

Write the simulation program for Round Robin with time quantum of 2 units. The arrival of time and first CPU bursts of different jobs should be input to the system. The output should give the Gantt chart and waiting time for each process and average waiting time.

Write the simulation program for Round Robin with time quantum of 2 units. The arrival of time and first CPU bursts of different jobs should be input to the system. The output should give the Gantt chart and waiting time for each process and average waiting time. Program: #include <stdio.h> #include <stdlib.h> #include <conio.h> struct ps{ int at,wt,bt,ft,st; }pr[50], temp[50]; int rq[50], time,x,n,t; void add(){ int i; for(i=0;i<n;i++){ if(time==pr[i].at){ rq[x++]=i; } } } int select(){ int pp, i; if(x==0){ return(-1); }else{ pp = rq[0]; for(i=0;i<x;i++){ rq[i]=rq[i+1]; } x--; return(pp); } } int main(void){ setbuf(stdout,NULL); float awt; int i,p; t=0; time=0; x=0; printf("Enter the Number of processes:"); scanf("%d",&n); for(i=0;i<n;i++){ printf("\nEnter Arrival Time:"); scanf("%d",&pr[i].at); printf("\nEnter CPU burst time:"); scanf("%d&

Write a Menu driven program in java for Insert Record into Table,Update the existing Record and Display all records from the table

Write a Menu driven program in java for the following: 1. Insert Record into Table 2. Update the existing Record 3. Display all records from the table  Program: import java.sql.*; import java.io.*; public class MenuRec { public statuc void main(String args[])throws SQLException, ClassNotFoundException, IOException { int ch,rollNo,marks,k; String name; String sql; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); COnnection con = DriverManager.getConnection("jdbc:odbc:MyDSN"); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); Statement stmt; do { System.out.println("Menu:"); System.out.println("1. Insert \n 2.Update \n 3.Display:"); System.out.println("Enter Choice:"); ch = Integer.parseInt(br.readLine()); switch(ch) { case 1: stmt = con.cre

Write a simulation program for scheduling algorithm using FCFS. The arrival time and first CPU burst of different jobs should be input to the system. The output should give the Gantt chart & turnaround time for each process and average turnaround time.

Write a simulation program for scheduling algorithm using FCFS. The arrival time and first CPU burst of different jobs should be input to the system. The output should give the Gantt chart & turnaround time for each process and average turnaround time. Program: #include <stdio.h> #include <stdlib.h> struct sch{ int at,st,bt,tat,ft; }pr[50]; int rq[50],x,n,timer; void addP(){ int i; for(i=0;i<n;i++){ if(pr[i].at==timer){ rq[x++]=i; } } } int selectP(){ int pp,i; if(x<0){ return(-1); }else{ pp=rq[0]; for(i=0;i<n;i++){ rq[i]=rq[i+1]; } x--; return(pp); } } int main(void){ setbuf(stdout,NULL); int i,t,p; float atat; timer = 0; x=-1; printf("Enter the number of processes:"); scanf("%d",&n); for(i=0;i<n;i++){ printf("\nEnter the Arrival time:"); scanf("%d",&pr[i].at); printf("\nEnter the Burst time:"); scanf("%d",&pr[i].bt); } t=0; addP(

Write a Java program to accept the details of student (rollNo, name, percentage) from the user and insert it into the table (Use PreparedStatement class)

Write a Java program to accept the details of student (rollNo, name, percentage) from the user and insert it into the table (Use PreparedStatement class) Program: import java.sql.*; import java.io.*; class Student { public static void main(String args[]) throws SQLException, ClassNotFoundException, IOException { String name; int rollNo; float percentage; char ch; BufferedReader br; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); COnnection con = DriverManager.getConnection("jdbc:odbc:studentDSN"); do { PreparedStatement stmt = con.prepareStatement("insert into student values(?,?,?)"); br = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter Roll No:"); rollNo = Integer.parseInt(br.readLine()); System.out.println("Enter Name:"); name = br.readLine();

Write a simulation program for disk scheduling using SCAN algorithm. Accept total number of disk blocks, disk request string, direction of head movement and current head position from the user. Display the list of request in order which it is served. Also display the total number of head movements.

Write a simulation program for disk scheduling using SCAN algorithm. Accept total number of disk blocks, disk request string, direction of head movement and current head position from the user. Display the list of request in order which it is served. Also display the total number of head movements. Program: #include<stdio.h> #include<conio.h> #include <string.h> int main2(void){ setbuf(stdout,NULL); int n,i,pr[50],cp,th,max,small,temp; char d; printf("\n Enter number of disk blocks:"); scanf("%d",&n); printf("\n Enter the current position of head:"); scanf("%d",&cp); printf("Enter the String:"); for(i=0;i<n;i++){ scanf("%d",&pr[i]); } printf("\nEnter the direction of head movement:"); scanf(" %c",&d); max=pr[0]; small=pr[0]; for(i=1;i<n;i++){ if(pr[i]>max){ max = pr[i]; } if(pr[i]<small){ small = pr[i]; } } if(d=='l

Write a Java program to accept the details of employee(eno, ename, salary) using AWT and insert into database

Write a Java program to accept the details of employee(eno, ename, salary) using AWT and insert into database. Program: import java.awt.*; import java.awt.event.*; import java.io.*; import java.sql.*; public class Employee extends Frame implements ActionListener { Label labelEno, labelEname, labelSalary; TextField textEno, textEname, textSalary; Button btnAdd; String sqlQuery; Statement s; Connection dbConnection; public Employee() throws ClassNotFoundException, SQLException { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); dbConnection = DriverManager.getConnection("jdbc.odbc:EmployeeDSN"); setLayout(new FlowLayout()); setSize(300,300); labelEno = new Label("Employee No:"); labelEname = new Label("Employee Name:"); labelSalary = new Label(Employee Salary:); textEno = new TextField(20); textEname = new TextField(20); textSalary = new TextField(20); btnAdd = new Button("Add"); btnAdd.addAction

Write a Program to implement "ls" command of UNIX with following options on DOS

Write a Program to implement "ls" command of UNIX with following options on DOS. "ls" to display files. "ls -a" to display all the hidden files. "ls -m" to display the files separated with commas. Program: #include<stdio.h> #include<stdlib.h> #include<string.h> #include<dirent.h> void ls(){ DIR *d; struct dirent *dn; char dr[20]; printf("Enter the Directory name:"); gets(dr); if((d=opendir(dr))==NULL){ printf("\nDirectory can't open"); } else { while((dn=readdir(d))!=NULL){ printf(" %s",dn->d_name); } } } void lsm(){ DIR *d; struct dirent *dn; char dr[20]; printf("Enter the Directory name:"); gets(dr); if((d=opendir(dr))==NULL){ printf("\nDirectory can't open"); } else{ while((dn=readdir(d))!=NULL){ printf("%s,",dn->d