-practical-assignment Final Ok.docx

  • Uploaded by: parwinder
  • 0
  • 0
  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View -practical-assignment Final Ok.docx as PDF for free.

More details

  • Words: 4,600
  • Pages: 69
PRACTICAL ASSIGNMENT 2018-19 SEMSESTER – 1

Submitted To:

Submitted By:

Chairperson USOL Panjab University, Chandigarh

DALJEET KAUR PGDCA Roll no:

ASSIGNMENT SUBJECT: PGD PR-1105 COMPUTER FUNDAMENTALS(PGD-1101)

Problem 1

(a) Prepare a document called lessonscript.doc, the document on any topic must have minimum 5 pages similar to the lesson scripts provided to you. Solution: Computer: Computer is an electronic device which performs arithmetic and logical operations and process data into information. Characteristics of computers: Automatic: Computers are automatic machines because once started on a job, they carry on, until the job is finished, normally without any human intervention. Speed: A computer is a very fast device. It can perform in few seconds, the amount of work that a human being can do in an entire year. Accuracy: The accuracy of computer is consistently high and the degree of accuracy of a particular computer depends upon its design. Diligence: Unlike human beings, a computer is free from monotony, tiredness and lack of concentration. It can continuously work for hours, without creating any error and without grumbling. Versatility: A computer is capable of performing almost any task, if the task can be reduced to a series of logical steps.

Four Basic Operations performed by computer: Input: For purpose of inserting data of computer by means of input devices. Process: Transform data into information by CPU. Output: Produce output on output device that shows the result of processing operations. Storage: Stores the result of processing operation at secondary memory.

Bock Diagram of Computer:

DATA

INPUT

MEMORY

OUTPUT

INFORMATION

CONTROL UNIT

ARITHMETIC AND LOGICAL UNIT

CPU (Central Processing Unit) The CPU is the brain of a computer system. All the major calculations and comparisons performed by a computer are carried out inside its CPU. The CPU is also responsible for activating and controlling the operations of other units of the computer system. Control Unit: It selects and interprets program instructions and then sees that they are executed. It manages and coordinates the entire computer system including the input and output units. It obtains instructions stored in the main memory, interprets the instructions and issue signals which causes other units of the system to execute them. Arithmetic and Logical unit: It is the place where the actual execution of the instructions takes place, during the data processing operation. It involves the arithmetic operations like addition, subtraction, multiplication, division and logic operation such as less than, greater than, equal to.

Memory: Every computer has a storage space which is known as primary storage or simple memory or main memory. It is a temporary storage area, which is built into the computer hardware and in which the instructions and data of the program resides, mainly when the program is being executed. There are two types of computer memory: Primary and Secondary. Primary Memory is accessible directly by the processing unit. RAM is an example of the primary memory. Secondary Memory such as floppy disks, magnetic disks etc are located outside the computer. Cache Memory is commonly used for minimizing the memory processor speed mismatch. It is extremely fast, small memory between CPU and main memory whose access time is closer to the processing speed of the CPU. It acts as a high speed buffer between the CPU and main memory. Input Devices: An input device is an electromechanical device, which accepts the data from the outside world and translates them into a form which the computer can interpret. They can broadly classified into the following categories. Keyboard devices Point and draw devices: Mouse, Trackball, Joystick, Electronic pen, Touch screen. Data scanning devices: Image scanner, OCR (optical character recognition) device, OMR (optical mark reader), Bar code reader, MICR (magnetic ink character recognition). Digitizer Electronic card reader Voice recognition devices Vision Input System Output Devices: An output device is an electrochemical device which accepts the data from a computer and translates them into a form, which is suitable for use by the outside world (the users). They are broadly classified into following categories: Monitors Printers: Dot-Matrix printers, Inkjet printers, Drum printers, laser printers. Plotters: Drum plotter, Flatbed plotter. Screen Image Projector Voice Response Systems: Speech Synthesizer.

Computer Hardware: Hardware is the term given to the machinery and the various individual pieces of the equipment. It refers to the physical devices of a computer system. The input, storage, processing, controlling, and output devices are hardware. Computer Software: The term software refers to the set of computer programs, procedures, and associated documents which describe the programs and how they are to be used. There are two types of software: System Software: It is a set of one or more programs, designed to control and extend the processing capabilities of a computer system. Examples: Operating systems, compliers, interpreters, linkers, loaders and device drivers etc. Application Software: It is a set of one or more programs, designed to solve a specific problem or do a specific task. Examples: Word processing software, spreadsheets, graphical software, entertainment software and presentation software. Types of computers: Analog Computers: They use the process of measurement of continuously varying quantities such as voltage and current for its operations. Digital Computers: They use the process of counting for its operations. By default a computer refers to a digital computer. Depending upon the computation speed, memory capability and accuracy the computers are named as personal, mainframe and super computers. Personal Computers (PCs) are less expensive and easy to handle and maintain, have limited speed, memory and accuracy compared to mainframe and super computers. Examples: IBM. Mainframe computers are powerful with more speed, memory and accuracy. They are of high initial cost and high maintenance cost. They are used in weather forecasting, satellite orbit determination etc.

(b) Write a letter called letter.doc to the co-coordinator PGDCA asking to send the lesson scripts as early as possible. Solution: The Coordinator PGDCA Department University School of Distance Learning Punjab University, Chandigarh. Subject: Request to send lesson scripts of PGDCA course Respected Sir/Madam, I am student of PGDCA for the batch year 2018-19. I have been enrolled for PGDCA course through distance mode (USOL). My enrollment no is…………... I have not received the lesson scripts of the above course till today. You are humbly requested to send the lesson scripts of PGDCA as early as possible so that I can make my comfortable time schedule. I shall be very thankful to you for this act of kindness. Yours faithfully Daljeet Kaur

PGDCA (USOL)

Problem 2 (a) Prepare pay slip (using MS Excel) for employees of an organization. The employee details must include employee code, name, father’s name, age, and address, date of joining, permanent or temporary. The pay slip must include Basic pay, dearness allowance, city allowance etc. The destruction must include insurance, loan advance etc. Compute net pay. (b) Compute and display the retirement date assuming retirement age is 60 years. Solution:

(CD IS ATTACHED WITH FILE FOR PROBLEM NO -2 A+B)

Problem 3 (a) Prepare a multimedia presentation using MS PowerPoint package. The presentation must have at least 10 slides for any of the lessons in your subjects PGD01, PGD02 ...or PGD06. (b) Create a custom animation for a drawing, image or a picture. Solution:

(CD IS ATTACHED WITH FILE FOR PROBLEM NO -3 A+B)

Problem 4 Create a text file called test using vi editor. (a) Allow the file to be read and executed by group and others. (b) Display the number of characters, words and lines in the file. (c) Send the file to another user. Solution: (a) To create a file called text 1. 2. 3. 4. 5.

Open the shell. Type “vi testfile.txt”. Go to insert mode by pressing “i” . Type text you want to & press “Esc”. Type “:wq” & press enter button.

File will be created. Now check default permissions. Type “ ls –l testfile.txt” Output: “ –rw-r- - r - -“ Now change permissions. Solution of the query: 1. 2. 3.

Type on shell “ chmed go+rx testfile.txt” Press enter & permissions will be set. Now check them by typing “ls –l testfile.txt”

Output: “-rw-r-xr-x” (b) To display the numbers of characters, words and lines in the file. Type on shell “wc –mlw testfile.txt” Output: 8 17 84 (where 8 is the number of lines, 17 is the number of words & 84 is the number of characters.) (c) To send the file to another user . Syntax: - mail username Example:-mail purva

Problem 5 Write a shell script. (a) to find the number of days between two dates. Solution: echo $(($(($(date -d "2010-06-01" "+%s") - $(date -d "2010-05-15" "+%s"))) / 86400))

Output:

(b) to find the sum, product and average of any N integers. Solution: echo Enter four integers with space between read a b c d sum=`expr $a + $b + $c + $d` avg=`expr $sum / 4` dec=`expr $sum % 4` dec=`expr \( $dec \* 1000 \) / 4` product=`expr $a \* $b \* $c \* $d` echo Sum=$sum echo Average=$avg.$dec echo Product=$product

Output:

(c) to display the user names, along with the processes they created. Solution: ps -U pgdca4

Output:

ASSIGNMENT SUBJECT: PGD 08 PRACTICAL RDBMS LAB

Consider the following tables.    

DEPARTMENT (DEPTNO, DEPTNAME, MANAGER_ID) EMPLOYEE (EMPNO, NAME, SEX, DESIGN_CODE, SALARY, COMMISSIC DEPT_NO) EMPHISTORY (EMPNO, FROM_DATE, TO_DATE, FROM_DEPT, TO_DEPT, FROM_DESIG, TO_DESIG, PROMO_FLAG, SALARY) DESIGNATION (DESIG_CODE, DESIG_NAME, MINSALARY, MAXSALARY, MANAGER_FLAG)

Write PROMO_FLAG and MANAGER_FLAG contain values “Y” or “N” Write either SQL code or the FoxPro program/programs to answer the following queries. Create above tables, add rows to tables and answer the following business queries. 1. 2. 3. 4. 5. 6. 7.

List the employees arranged department number wise and then by name. List all designation coded from EMPPLOYEE omitting duplicates. Who is the highly paid employee in the company? Which managers have salary between Rs. 4000 and Rs. 5000? List all managers who are not in dept_no ‘01’ and whose name begin with ‘G’. Which clerks were hired in or after Mar-2000? Which employees, when starting their careers, either were not programmers first or had starting salaries of least Rs. 5000? 8. What is the maximum, minimum, and average salary of male & female employees? 9. List the name, annual salary, commission, and total annual income for each employee arranged in descending order of their income. 10. List the employees who have the same job as that of ‘Surinder’? 11. Which women employees earn more than average salary of men? 12. What is the name of employee Sonia’s department manager? 13. Which employees have ever got promotion into a managerial job? Show the EmpNo, Name and current job?

Solution: Create Table Command: CREATE TABLE DEPARTMENT (DEPTNO number, DEPTNAME varchar(100), MANAGER_ID number); Insert into department values (101, ‘Law’, 3); Insert into department values (102, ‘chemistry’, 4); Insert into department values (103, ‘physics’, 05); Insert into department values (104, ‘chemistry’, 6); Insert into department values (105, ‘english’, 7); Insert into department values (106, ‘punjabi’, 8); CREATE TABLE EMPLOYEE (EMPNO number, NAME varchar(100), SEX varchar(1), DESIG_CODE number, SALARY number, COMMISSIC varchar(100), DEPTNO number); insert into employee values (1, 'Sunil', 'M', 50, 20000,2600,104); insert into employee values (2, 'Sweety', 'F', 60, 30000,1000,103); insert into employee values (3, 'Happy', 'M', 60, 25000,300,103); insert into employee values (4, 'Gurveer', 'M', 45, 21000,4000,101); insert into employee values (5, 'Neha', 'F', 30, 23000,2300,106); insert into employee values (6, 'Preety', 'F', 30, 10000,2100,105); CREATE TABLE EMPHISTORY (EMPNO number, FROM_DATE date, TO_DATE date, TO_DEP varchar(100), FROM_DESIG varchar(100), PROMO_FLAG varchar(1), SALARY number); insert into EMPHISTORY values (1, '1-Feb-14', '1-Feb-15', 'chemistry', 'Assistant', 'N', 15000); insert into EMPHISTORY values (2, '1-Sep-12', '4-Feb-14', 'botany', 'Teacher', 'Y', 25000); insert into EMPHISTORY values (3, '2-Aug-13', '7-Mar-15', 'law', 'Staff', 'Y', 10000); insert into EMPHISTORY values (4, '5-mar-14', '5-Aug-15', 'chemistry', 'Assistant', 'N', 20000); insert into EMPHISTORY values (5, '1-Apr-14', '10-Apr-15', 'physics', 'Supervisor', 'N', 40000); insert into EMPHISTORY values (6, '1-Feb-12', '11-Apr-15', 'law', 'Teacher', 'Y', 30000); CREATE TABLE DESIGNATION (DESIGN_CODE number, DESIG_NAME varchar(100), MINSALARY number, MAXSALARY number, MANAGER_FLAG varchar(1)); insert into DESIGNATION values (1001, ‘Teacher’, 30000, 70000, ‘N’); insert into DESIGNATION values (1002, ‘Assistant’, 11000, 65000, ‘N’); insert into DESIGNATION values (1003, ‘Staff’, 5000, 79000, ‘N’); insert into DESIGNATION values (1004, ‘Supervisor’, 30000, 70000, ‘N’); insert into DESIGNATION values (1005, ‘Manager’, 40000, 90000, ‘Y’); insert into DESIGNATION values (1006, ‘Clerk’, 35000, 100000, ‘N’);

Queries: 1. 2. 3. 4.

SELECT * FROM EMPLOYEE ORDER BY DEPTNO, NAME; SELECT DISTINCT DESIG_CODE FROM EMPLOYEE; SELECT MAX(SALARY)FROM EMPLOYEE; SELECT * FROM EMPLOYEE WHERE DESIG_CODE IN (SELECT DESIG_CODE FROM DESIGNATION WHERE MANAGER_FLAG = ‘Y’) AND SALARY >=4000 AND SALARY<=5000; 5. SELECT * FROM EMPLOYEE WHERE DESIG_CODE IN (SELECT DESIG_CODE FROM DESIGNATIONWHERE MANAGER_FLAG = ‘Y’) AND DEPT_NO <> ‘01’ AND NAME LIKE ‘G%’; 6. SELECT EMPNO FROM EMPHISTORY WHERE FROM_DATE >=’2000/03/01’ AND FROM_DESIG IN (SELECT DESIG_CODE WHERE DESIG_NAME = ‘CLERK’); 7. SELECT EMPNO FROM EMPHISTORY WHERE (FROM_DESIG <> ‘PROGRAMMER’ OR SALARY >= 5000) AND PROMO_FLAG = ‘N’; 8. SELECT EMPNO, SEX, MAX(SALARY), MIN(SALARY), AVG(SALARY) FROM EMPLOYEE GROUP BY EMPNO, SEX; 9. SELECT NAME, SALARY, COMMISSIC, SALARY+COMMISSIC FROM EMPLOYEE ORDER BY SALARY+COMMISSIC DESC; 10. SELECT * FROM EMPLOYEE WHERE DESIG_CODE = (SELECT DESIG_CODE FROM EMPLOYEE WHERE NAME = ‘Surinder’); 11. SELECT * FROM EMPLOYEE WHERE SALARY > (SELECT AVG(SALARY) FROM EMPLOYEE WHERE SEX = ‘M’) AND SEX = ‘F’; 12. SELECT NAME FROM EMPLOYEE WHERE EMPNO = (SELECT MANAGER_ID FROM DEPARTMENT WHERE DEPTNO = (SELECT DEPTNO FROM EMPLOYEE WHERE NAME = ‘Sonia’)); 13. SELECT EMPNO, NAME, DESIG_CODE FROM EMPLOYEE WHERE EMPNO = (SELECT DISTINCT EMPNO FROM EMPHISTORY WHERE FROM_DESIG = ‘MANAGER’ AND PROMO_FLAG = ‘Y’);

ASSIGNMENT SUBJECT: PGD 09 PRACTICAL PROGRAMMING LAB IN C/C++

Problem 1 Write the program oddsum () in C with function head int oddsum (int n) The function should return the sum of all odd numbers between 1 and n (including 1 and n and you may assume that n=>1). For example, the call oddsum (7) should give the result 1+3+5+7=16 while the call oddsum (12) should give the result 1+3+5+7+9+11=36. Write a main function that tests oddsum () by reading an integer from the keyboard, and if the integer is positive oddsum () should be called and the returned value is written on the screen. Solution: #include<stdio.h> #include Int oddum(int); Void main() { Int n,sum; clrscr(); block:printf(“\n Enter a number \n”); scanf(“%d”,&n); if(n>=1) { sum=oddsum(n); printf(“\n The sum of odd numbers between 1 & %d is %d.”,n,sum); } Else { printf(“\n Please enter a positive number”);

goto block; } getch(); } int oddsum(int m) { Int I,res; res=0; for(i=1;i<m;i++) { If(i%2==1) { res=res+I; } } return(res); }

Output:

Problem 2 Write a function in C with name magic and the input parameters A and n. A is an integer matrix of order n. The function should check if the matrix A fulfills the conditions for being a magic square. It should return the magic number if A is “magic”. Otherwise zero should be returned. The function should be able to handle matrices declared int matA [10] [10] int magic (intA [] [10], intn) Example of a magic square of order 3 with the magic number 24 i.e. all row sums, all column sums and both the diagonal sums should be equal yo say that the matrix is a magic square. Solution: #include<stdio.h> #include int magic(int a[][10],int); void main() { int matA[10][10]; int I,j,k,res; clrscr(); printf(“\n Please enter the order of matrix: “); scanf(“%d”,&k); printf(“\n Please enter the elements of matrix \n”); for(i=0;i
scanf(“%d”,&matA[i][j]); } } res=magic(matA,k); if(res==0) { printf(“\n This is not a Magic Square. \n”); } else { printf(“\n This is a Magic Square with Magic number %d”,res); } getch(); } int magic(int mat[][10],int n) { int p,q,row,col; int dial=0; int diar=0; for(p=0;p
row=row+mat[p][q]; col=col+mat[q][p]; if(p==q) { dial=dial+mat[p][q]; } if((p+q)==(n-1)) { diar=diar+mat[p][q]; } } } if(row==dial&col==diar) { return diar; } else { return 0; } }

Output:

Problem 3 Study the following program and answer the following questions. # include <stdio.h> void mixtra (int x, int *y); { int c; c = x+ *y; x = c+1; *y = c+1; c = c = 1; printf (“\n%d %d %d\n”,x, *y,c); } void main (void) int a, b; int *c; a = 1; b = 2; c = &b; printf (“\n%d %d %d\n”,a, b, *c); /* */ printf (“\ \~%d %d/n”,a, b, *c); At /* */ a call to mixtra is done. What is written by the program if the call is: a. mixtra (a, &b); b. mixtra (b, &a); c. mixtra (a, &a); d. mixtra (a,c);

Solution: a) mixtra (a, &b); #include<stdio.h> #include void mixtra(int x,int*y) { int c; c=x+*y; x=c+1; *y=c+1; c=c=1; printf(“\n %d%d%d \n”,x,*y,c); } void main() { int a,b; int *c; a=1; b=2; c=&b; clrscr(); printf(“\n %d%d%d \n”,a,b,*c); mixtra(a,&b); printf(“\n %d%d%d \n”,a,b,*c);

getch(); }

Output:

b) mixtra (b, &a); #include<stdio.h> #include void mixtra(int x,int*y) { int c; c=x+*y; x=c+1; *y=c+1; c=c=1; printf(“\n %d%d%d \n”,x,*y,c); } void main() { int a,b; int *c; a=1; b=2; c=&b; clrscr(); printf(“\n %d%d%d \n”,a,b,*c); mixtra(a,&b); printf(“\n %d%d%d \n”,a,b,*c); getch();

}

Output:

c) mixtra (a, &a); #include<stdio.h> #include void mixtra(int x,int*y) { int c; c=x+*y; x=c+1; *y=c+1; C=c=1; Printf(“\n %d%d%d \n”,x,*y,c); } void main() { int a,b; int *c; a=1; b=2; c=&b; clrscr(); printf(“\n %d%d%d \n”,a,b,*c); mixtra(a,&a); printf(“\n %d%d%d \n”,a,b,*c); getch();

}

Output:

d) mixtra (a,c); #include<stdio.h> #include void mixtra(int x,int*y) { int c; c=x+*y; x=c+1; *y=c+1; C=c=1; Printf(“\n %d%d%d \n”,x,*y,c); } void main() { int a,b; int *c; a=1; b=2; c=&b; clrscr(); printf(“\n %d%d%d \n”,a,b,*c); mixtra(a,c); printf(“\n %d%d%d \n”,a,b,*c); getch();

}

Output:

Problem 4 Explain what the recursive function below does. Do not describe, row by row, what the function does, rather you should explain what problem the function solves. void secret (int number) { Assert (munber >=0); If (number) secret (number/2) printf (“%d”, number %2); } Illustrate your explanation by showing what happens when the function is called by secret (12). Solution: #include<stdio.h> #include #include void secret(int); void main() { int n; clrscr(); n=12; secret(n); getch(); } void secret(int number) { assert(number>=0);

if(number) secret(number/2); printf(“%d”,number%2); }

Output:

Problem 5 A palindrome is a string that sounds the same independent of it is read from left to right or from right to left. The examples of the palindrome are ; “abba”, “otto”, “123321”, “I am ma I”, “C”, “Anna”. Write a function in C++ that takes a string as the single parameter and returns the integer 1 if the string is a palindrome. Otherwise zero should be returned. Extend this program to read a paragraph from a file and then find out the palindromes in that paragraphs. Solution: #include #include<stdio.h> #include #include<string.h> int palindrome(char a[20]); int main() { char a[20]; int res; clrscr(); cout<<”Enter a string:”; gets(a); res==palindrome(a); if(res==1) { Cout<<”\n Entered string is a palindrome”; } else {

cout<<”\n Entered string is not a palindrome”; } getch(); return 0; } int palindrome(char b[20]) { char c[20]; strcpy(c,p); strrev(c); if((strcmp(b,c))==0) { return 1; } else { return 0; } }

Output:

Problem 6 Write a program in C++ to create the following report. Create a class student and add functions setData, getData and showData to set, read, and display values. The output should appear as shown below: List of PGDCA students Roll# Name Marks1 Marks2 Total Marks 001 Akash 70 67 137 002 Aneesh 71 34 105 003 Baltej 57 43 100 Solution: #include #include<stdio.h> #include class student { int roll,marks1,marks2,tmarks; char name[20]; public: void getdata() { Cout<<”\n Enter roll no.:”; Cin>>roll; cout<<”\n Enter name:”; gets(name); cout<<”\n Enter marks1:”; cin>>marks1; cout<<”\n Enter marks2:”;

cin>>marks2; tmarks=marks1+marks2; } void showdata() { cout<<”\t”<
} getch(); }

Output:

ASSIGNMENT SUBJECT: PGD 10 PRACTICAL WEB PROGRAMMING LAB

Problem 1 Make a web site for the ABC Institute. List the various departments present in the institute. Insert picture of the institute on the home page. Use the different heading levels to display the text and use different colors for the headings and text in the paragraphs. Solution: HOME

>
inst
height="500">



PASTE PRINTSCREEN HERE

DEPARTMENT

DEPARTMENTS OF

INSTITUTE

<style> table,th,td { border:1px solid black; border-collapse:collapse; } th,td { padding:5px; }



SR.NO
NAME OF DEPARTMENT
NUMBER OF SEATS
1
Arts
40
2
Business Management and

Commerce
40
3
Engineeering and Technology
40
4
Law
40
5
Science
40
6
Education
40



PASTE PRINTSCREEN HERE

Problem 2 Create a website for the XYZ Company. List the names of the mangers. Each name should be linked to his/her personal information page. Solution: XYZ Company

<marquee> XYZ Company

XYZ is India’s largest online marketplace for Small & Medium Size Businesses, connecting global

buyers with suppliers. The company offers a platform & tools to over 1.5 million suppliers to generate business leads from over 10

million buyers, who use the platform to find reliable & competitive suppliers. The company has over 2600 employees located across

40+ offices in the country. Its existing investors include Intel Capital and Bennett, Coleman & Co. Ltd.
XYZcompany.com offers products that enable small & medium size businesses generate business leads (online catalogs/store-

fronts), establish their credibility (third party verified trust profile) and use business information (finance, news, trade shows,

tenders) for their business promotion.
XYZcompany.com has won numerous awards and significant nominations over the years, which include coveted Manthan Award,

Red Herring Award and Emerging India Award respectively among others. The company has also been widely covered by media for

its pioneering role in promoting SME business in the country.

Company's products and thier details:

You can also go through the details of our company's managers:

Dinesh Agarwal (Product & Technology)

Prateek Chandra (Client Servicing Division)

Sudhir Gupta (Finance and Accounts)

Vinita Tikoo Koul (HR & Administration)

Vikram Khanna (Sales Division)

PASTE PRINTSCREEN HERE

Problem 3 For the XYZ Company site, create a table to show the details of the products they manufacture. Format the table. Solution:

PASTE PRINTSCREEN HERE

Problem 4 Create your personal website giving your family details, education details, and friends’ information on different pages of the site. Solution: MY PROFILE

<marquee> My Personal Web Site

This is Mallika Arora pursuing PGDCA from Panjab University.

MY EDUCATIONAL QUALIFICATION:
Graduation - B.Sc (Hons.)in Botany from Panjab University
Post Graduation - M.Sc(Hons.) Botany from Panjab University

You can know more about me by clicking on the following links:
PASTE PRINTSCREEN HERE

Problem 5 For the above created personal website, add a form to gather information (name, email address, users’ educational qualification, his/her hobbies, how he came to know about site, suggestions on the site) from the user. Solution: Suggestions

<marquee>

Suggestions







First name:
Last name:
E-mail:      
Qualification/Education: Graduation
type="checkbox" name="qualification-education" value="Post Graduation"> Post Graduation
Hobbies:







PASTE PRINTSCREEN HERE

Problem 6 Write a Java program to print the Fabonacci series. Solution: Java program to print the Fabonacci series: class Fabonacci { public static void main(String[] args) { int low=1; int high=0; while(high<50) { System.out.println(high); int temp=high; high=high+low; low=temp; } } }

Output:

Problem 7 Create a Java class “graphics”. Let triangle, circle and rectangle classes inherit that. Design the relevant member functions and variable for each. Solution: public class graphics { public static void main(String args[]) { triangle t1 = new triangle(); rectangle r1 = new rectangle(); circle c1 = new circle(); t1.tri(); r1.rect(); c1.cir(); } } class triangle extends graphics { public void tri() { System.out.println("\n\n------>> Here Starts triangle <<--------\n"); System.out.println("\n--------------------------"); } } class rectangle extends graphics { int height=20,width=50; public void rect() { System.out.println("\n\n------>> Here Starts Rectangle <<--------\n");

System.out.println("height of rectangle:"+height); System.out.println("width of rectangle:"+width); System.out.println("area of rectangle:"+height*width); System.out.println("\n--------------------------");

} } class circle extends graphics { int radius=50; public void cir() { System.out.println("\n\n------>> Here Starts Circle <<--------\n"); System.out.println("cirlce is having its radius as: "+radius); System.out.println("\n--------------------------");

} }

Problem 8 Write a Java program to divide two numbers. Avoid division by zero by catching the exception. Solution: Java program to divide two numbers: import java.util.Scanner; class Division { public static void main(String[] args) { int a, b, result; Scanner input = new Scanner(System.in); System.out.println("Input two integers"); a = input.nextInt(); b = input.nextInt(); // try block try { result = a / b; System.out.println("Result = " + result); } // catch block catch (ArithmeticException e) { System.out.println("Exception caught: Division by zero."); } } }

Output:

Problem 9 Create a Java applet to display your address on the screen. Use different colors for background and text. Solution: Java applet to display address on the screen: import java.applet.*; import java.awt.*; public class app extends Applet { public void paint(Graphics g) { //Draw a rectangle width=250, height=100 g.drawRect(0,0,350,250); //Set the color to yellow g.setColor(Color.yellow); setBackground(Color.blue); //Write the message to the web page g.drawString("my address is #2542 chandigarh",10,50); } } /* */ One HTML file is required

Output:

CHANGE PRINTSCREEN HERE

Problem 10 Write a program to demonstrate the usage of threads. Run two different loops through two different threads and print the numbers from 1-20. Solution: Program to demonstrate the usage of threads: class MyThread extends Thread { @Override public void run() { for(int i = 1; i <= 20; i ++) { System.out.println("[ID " + this.getId() + "] " + i); } } } public class threads { public static void main(String [] args) { MyThread t1 = new MyThread(); MyThread t2 = new MyThread(); t1.start(); t2.start(); } }

Output:

Related Documents

Ais Final Final Final
November 2019 111
Final Final
June 2020 55
Final
June 2020 2
Final
June 2020 6

More Documents from ""