• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content







Total Views
Views on SlideShare
Embed Views



0 Embeds 0

No embeds



Upload Details

Uploaded via as Microsoft Word

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment


    • Class XII - Informatics Practices (065) PRACTICAL–ASSIGNMENTS PART 1 JAVA Experiment No. 1: Objective: Understanding and use of variables of float and other data types. Task: Develop a simple Calculator application as per given screen snapshot, toImplement +, -, x and / operations. The text boxes get cleared when „C‟ buttonis clicked. Public Class :Float n1,n2,res; char op; 1.CLEAR Button:t1.setText(null); t2.setText(null); t3.setText(null); t3.setText(null); 1
    • 2.EXIT Button:System.exit(0); 3.+ Button:n1=Float.parseFloat(t1.getText()); n2=Float.parseFloat(t2.getText()); res=n1+n2; t3.setText(""+res); 4.- Button:n1=Float.parseFloat(t1.getText()); n2=Float.parseFloat(t2.getText()); res=n1-n2; t3.setText(""+res); 5. *Button:n1=Float.parseFloat(t1.getText()); n2=Float.parseFloat(t2.getText()); res=n1*n2; t3.setText(""+res); 6. / Button:n1=Float.parseFloat(t1.getText()); n2=Float.parseFloat(t2.getText()); res=n1/n2; t3.setText(""+res); 2
    • Experiment No. 2: Objective: Understanding the real life application requirement and developing a solution. Task: Develop a Compound Interest Calculator application as per given screensnapshot, to calculate total amount for given Amount, Rate of Interest andTime using (A=P(1+R/100) T) and Interest I=A-P. Public Class :float p,r,n,res,intamt; 1. CALCULATE BUTTON :p=Float.parseFloat(txtPA.getText()); r=Float.parseFloat(txtRate.getText()); n=Float.parseFloat(txtDur.getText()); res=(p*r*n)/100; intamt=p-res; txtSI.setText(""+res); Tfintamt.setText(""+intamt); 2. Clear Button :txtPA.setText(""); txtRate.setText(""); txtDur.setText(""); txtSI.setText(""); 3. EXIT Button System.exit(0) 3
    • Experiment No. 3: Objective: Understanding and use of Nested conditions in the Real life applications. Task: A Quick Fox Transport Co. wants to develop an application for calculatingAmount based on distance and weight of goods.The charges (Amount) to be calculated as per rates given below. Distance >=500 Km <500 Km Weight >=100 kg. >=10 and <100 kg. < 10 kg. >=100 Kg. <100 Kg. Public Class :int w,d,a; 1. Calculate Button :t1.getText(); t2.getText(); w=Integer.parseInt(t3.getText()); d=Integer.parseInt(t4.getText()); if(d>=500 && w>=100) { 4 Charges per Km. Rs. 5/Rs. 6/Rs. 7/Rs.8/Rs.5/-
    • a=d*5; t5.setText(""+a); } else if(d>=500 && w<100 && w>=10) { a=d*6; t5.setText(""+a); } else if(d<=500 && w<10) { a=d*7; t5.setText(""+a); } else if(d<500 && w>=100) { a=d*8; t5.setText(""+a); } else if(d<500 && w<100) { a=d*5; t5.setText(""+a); } 2. Exit Button :System.exit(0); 5
    • Experiment No. 4: Objective: Understanding and use of Nested loops and Text Area control. Task: Develop a Java application to print a Pattern for given character and steps, asper given screen shot. Public Class :char s; String s1; int n; 1. GENERATE BUTTON :s1=t1.getText(); s=s1.charAt(0); n=Integer.parseInt(t2.getText()); for(int i=1;i<=n;i++) { for(int j=1;j<=i;j++) { ta1.append(""+s+"n"); } } 2. CLEAR BUTTON :t1.setText(null); t2.setText(null); ta1.setText(null); 6
    • Experiment No. 5: Objective: Understanding the use of loops and mathematical operations. Task: Develop an application to compute the sum of digits for given number. Public Class :int no,sum,r; 1.Calculate it Button :r=0; no=Integer.parseInt(t1.getText()); while(no>0) {r=(no%10)+(r*10); sum=(no%10)+ sum; no/=10; } ts.setText(""+sum); 2.Clear Button :t1.setText(""); ts.setText(""); 3.Exit Button :System.exit(0); 7
    • Experiment No. 6: Objective: Understanding and developing logic to solve a problem.Use of nested loopsand breaking it prematurely. Task: Develop a Prime Number Generator Application which generates Prime numbersfor given range. Prime numbers are those numbers which are divisible by one or itself only. Public Class :-int l,h,r,f; 1. Generate Button :l=Integer.parseInt(t1.getText()); h=Integer.parseInt(t2.getText()); for(r=l;r<=h;r++) {f=0; for(int j=2;j<r/2;j++) { if(r%j==0) { f=1; break; } } if(f==0) { ta1.append(""+r+"n"); } Exit Button :System.exit(0); 8
    • Experiment No. 7: Objective: Displaying images on a Label and Text Area control. Task: Develop an e-Learning application with images and text information as pergiven screen shot. 1. Keyboard pic.setIcon(new ImageIcon("C:Documents and SettingsStudentMy DocumentsNetBeansProjectsoffer_of_the_dayapplewireless.png")); ta.setText("Offer Price:Rs 5,400/-.n"+ "Maximum Retail Price:Rs 6,700/-.n"+ " Set the keyboard on your desk, and you’ll see that it takes up far less space — up to 24 percent less — than other full-size keyboards. And you have even more room to mouse comfortably alongside of it. You’ll also feel a difference when you type. Your hands will appreciate the low-profile aluminium enclosure and the crisp, responsive keys. Use the new wireless Magic Mouse alongside the Apple Wireless Keyboard and get the full effect of a cable-free (and clutter-free) 9
    • desk.Use the function keys for one-touch access to a variety of Mac features including Mission Control and Launchpad."); 2.Mouse pic.setIcon(new ImageIcon("C:Documents and SettingsStudentMy DocumentsNetBeansProjectsoffer_of_the_daymouse.png")); ta.setText("Offer Price: Rs 3,200/-.n"+"Maximum Retail Price:Rs 3,900/-.n"+ "The Multi-Touch area covers the top surface of Magic Mouse, and the mouse itself is the button. Scroll in any direction with one finger, swipe through web pages and photos with two, and click and double-click anywhere. Inside Magic Mouse is a chip that tells it exactly what you want to do. Which means Magic Mouse won’t confuse a scroll with a swipe. It even knows when you’re just resting your hand on it.Laser-Tracking EngineMagic Mouse uses powerful laser tracking that’s far more sensitive and responsive on more surfaces than traditional optical tracking. That means it tracks with precision on nearly every surface —."); 3.Monitor pic.setIcon(new ImageIcon("C:Documents and SettingsStudentMy DocumentsNetBeansProjectsoffer_of_the_daymonitor.png")); ta.setText("Offer Price: Rs 69,999/-.n"+"Maximum Retail Price: Rs 1,09,999/-n"+ "LED backlighting. Bright on.Full brightness with no waiting. That’s the big advantage of LED backlight technology. Unlike most displays that take time to warm up before they reach maximum brightness, an LED-backlit display is instantly on and uniformly bright. LED backlighting also gives you greater control over screen brightness. So you can tune the Thunderbolt Display to suit the ambient light in even the dimmest room."); 4.Printer pic.setIcon(new ImageIcon("C:Documents and SettingsStudentMy DocumentsNetBeansProjectsoffer_of_the_dayprinter.png")); 10
    • ta.setText("Offer Price: Rs 16,750/-n"+"Maximum Retail Price:Rs 19,650/-n"+ "The PIXMA Printing Solutions App available on both iOS and Android platforms, gives users a lot more functionality with their printers. Using a smartphone or tablet device, users can print documents and images stored on their devices, or scan a document directly into their devices."); 5.Modem pic.setIcon(new ImageIcon("C:Documents and SettingsStudentDesktopexp7modem.png")); ta.setText("Offer Price:Rs 3,600/-n"+"Maximum Retail Price:Rs 4,000/-n"+ "Enjoy fast wireless connectivity for your home or office. The Wireless-N Home ADSL2 Modem Router has a built-in high-speed ADSL2 Modem for a fast, "Always On" connection to the Internet. Wireless connections use Wireless-N technology for fast data transfers, and the four built-in 10/100 Ethernet ports supply high-speed connections to your wired devices. "); 11
    • Experiment No. 8: Objective: Demonstration of use of List Dynamically through code. Task: Develop an application as per given screen shot to Add , Remove the givenmembers of list and display the selected item in a text field using List control. Public Class :String a,r,s; 1. Add Button :DefaultListModel dd=(DefaultListModel) li1.getModel(); a=t2.getText(); dd.addElement(a); t2.setText(""); 2. Remove Button :int s; DefaultListModel d=(DefaultListModel) li1.getModel(); s=Integer.parseInt(t3.getText()); d.removeElementAt(s); 3. Clear List Button :DefaultListModel d=(DefaultListModel) li1.getModel(); dd.removeAllElements(); 4. List Value changed :-t1.setText(li1.getSelectedValue().toString()); 12
    • Experiment No. 9: Objective: Understanding and use of the Radio Button in Real-life application to determine the selection of choice and calculations accordingly. Task: Develop a Billing application for Happy Shopping- A retail chain involved in sales of readymade garments. The happy Shopping offers discount to its members holding Platinum, Gold and Silver card. The 10% discount is given to Platinum card, 8% to Gold Card and 5% to SilverCard holders on sales amount. Public Class :float r,q,ta,d,na; 1. Calculate Button :r=Float.parseFloat(t1.getText()); q=Float.parseFloat(t2.getText()); if(r1.isSelected()==true) { ta=r*q; t3.setText(""+ta); d=ta*10/100; t4.setText(""+d); na=ta-d; 13
    • t5.setText(""+na); } if(r2.isSelected()==true) { ta=r*q; t3.setText(""+ta); d=ta*8/100; t4.setText(""+d); na=ta-d; t5.setText(""+na); } if(r3.isSelected()==true) { ta=r*q; t3.setText(""+ta); d=ta*5/100; t4.setText(""+d); na=ta-d; t5.setText(""+na); } 2. Clear Button :tName.setText(null); t1.setText(null); t2.setText(null); t3.setText(null); t4.setText(null); t5.setText(null); r1.setSelected(false); r2.setSelected(false); r3.setSelected(false); 3. R1 Radio Button :if(r1.isSelected()==true) r2.setSelected(false); r3.setSelected(false); 14
    • 4. R2 Radio Button :if(r2.isSelected()==true) { r1.setSelected(false); r3.setSelected(false); } 5. R3 Radio Buttton :if(r3.isSelected()==true) { r1.setSelected(false); r2.setSelected(false); } 6. Exit Button :System.exit(0); 15
    • Experiment No. 10: Task: The Entertainment Paradise- A theater in Delhi wants to develop a computerized Booking System. The proposed Interface is given below. The theater offers different types of seats. The Ticket rates areStalls Rs. 625/Circle Rs.750/Upper Class Rs.850/ Box Rs.1000/A discount is given 10% of total amount if tickets are purchased on Cash. In case of credit card holders 5% discount is given. Public Class :-int ta,d,na,ts; 1. Calculate Button :ts=Integer.parseInt(tf1.getText()); if(rstalls.isSelected()==true) { if(rcash.isSelected()==true); { ta=625*ts; d=ta*10/100; na=ta+d; t1.setText(""+ta); t2.setText(""+d); 16
    • t3.setText(""+na); } if(racredit.isSelected()==true) { ta=625*ts; d=ta*5/100; na=ta+d; t1.setText(""+ta); t2.setText(""+d); t3.setText(""+na); } } if(rcircle.isSelected()==true) { if(rcash.isSelected()==true); { ta=750*ts; d=ta*10/100; na=ta+d; t1.setText(""+ta); t2.setText(""+d); t3.setText(""+na); } if(rcredit.isSelected()==true) { ta=750*ts; d=ta*5/100; na=ta+d; t1.setText(""+ta); t2.setText(""+d); t3.setText(""+na); }} if(rupperclass.isSelected()==true) { if(rcash.isSelected()==true); { ta=900*ts; 17
    • d=ta*10/100; na=ta+d; t1.setText(""+ta); t2.setText(""+d); t3.setText(""+na); } if(rcredit.isSelected()==true) { ta=900*ts; d=ta*5/100; na=ta+d; t1.setText(""+ta); t2.setText(""+d); t3.setText(""+na); }} if(rbox.isSelected()==true) { if(rcash.isSelected()==true); { ta=1050*ts; d=ta*10/100; na=ta+d; t1.setText(""+ta); t2.setText(""+d); t3.setText(""+na); } if(rcredit.isSelected()==true) { ta=1050*ts; d=ta*5/100; na=ta+d; t1.setText(""+ta); t2.setText(""+d); t3.setText(""+na); } } 2. Exit Button :-System.exit(0); 18
    • Experiment No. 11: Objective: Understanding the use of various controls in Real life application. Task: ABC Consultancy is a placement organization, assists job seekers. The Entry form has to be designed to facilitate the Registration Process with following features. 1. When Submit button is pressed, the following things should happen. (a) If Post Graduate is checked, the 10+2 and Graduate checkboxes should also get selected automatically. (b) If Graduate is checked, the 10+2 checkboxes should also get selected. (c) A Message Box with “Hello Mr. ….. You are registered” or “Hello Miss… ….. You are registered” as per Gender of candidate. 2. When Clear Button is pressed, all the text boxes, check boxes get cleared, and Male and Science option is selected by default. Public Class :String str; 1. Submit Button :if (pgra.isSelected()) { gra.setEnabled(true); ten.setEnabled(true); } if (gra.isSelected()== true){ 19
    • ten.setEnabled(true); } String str=null; if (mr.isSelected()) { str="hello Mr." + t1.getText()+ "you are registered."; } else if (fm.isSelected()){ str="Hello Miss"+t1.getText()+"you are registered"; } JOptionPane.showMessageDialog(null, str); 2. Clear Button :ten.setSelected(false); gra.setSelected(false); pgra.setSelected(false); t1.setText(null); mr.setSelected(false); fm.setSelected(false); sci.setSelected(false); Comm.setSelected(false); art.setSelected(false); 3. Male Radio :if(ramale.isSelected()==true) { rafemale.setSelected(false); } 4. Female Radio :if(rafemale.isSelected()==true) { ramale.setSelected(false); } 5. 10+2 Checkbox :- 20
    • 6. Graduate Check Box :if(cbgrad.isSelected()==true) { cb10.setSelected(true); } 7. Post Graduate Check Box :if(cbpg.isSelected()==true) { cb10.setSelected(true); cbgrad.setSelected(true)} 21
    • Experiment No. 12: Objective: Understanding the need of Real life applications. Task: The Milton Casting Company has developed an application to calculate the wage of its workers. The following functionalities are expected. 1. The Wage rate are Rs.150/- (per day) for male and Rs.130/- for females. 2. An additional amount Rs.50/- per day is paid if worker is skilled. 3. When Calculate Button is clicked the Total wage amount is calculated and is played in relevant Text box. 4. When Clear Button is clicked, all the text boxes get cleared and Male option is selected. Public Class :int d,ta; 1. Calculate Button :d=Integer.parseInt(t2.getText()); if(ch1.isSelected()==true) { if(ra1.isSelected()==true) { ra2.setSelected(false); 22
    • ta=d*200; t3.setText(""+ta); } if(ra2.isSelected()==true) { ra1.setSelected(false); ta=d*180; t3.setText(""+ta); } } if(ra1.isSelected()==true) { ra2.setSelected(false); ta=d*150; t3.setText(""+ta); } if(ra2.isSelected()==true) { ra1.setSelected(false); ta=d*130; t3.setText(""+ta); } 23
    • 2. Clear Button :t1.setText(null); t2.setText(null); t3.setText(null); ra1.setSelected(false); ra2.setSelected(false); ch1.setSelected(false); 3. Exit Button :System.exit(0); 24
    • Experiment No. 13: Objective: Understanding the need of Real life applications. Task: The Fashion Gallery- a leading garments shop wants to develop an application tocalculate the discount Amount. The following functionalities are expected. 1. The discount is given on the basis on payment mode. Cash – 10% Cheque – 8% Credit – 5% If Bill amount is more than 10000 then additional 5% discount is also given. 2. Initially, Calculate Net Amount is disabled, but when user click on Calculate Discount button the discount amount is calculated and displayed and Calculate Net Amount Button is enabled. 3. When Calculate Net Amount is clicked the Net Amount is calculated and displayed in Net Amount Text Box. 4. When Exit Button is clicked, a Confirm dialog appears and application is closed only when Yes option in confirm dialog is selected. Public Class :float ba,d,na; String a; 1.Calculate Discount Button :ba=Float.parseFloat(t2.getText()); 25
    • if(ba>10000) { if(c1.getSelectedItem().equals("Cash")) { d=ba*15/100; t3.setText(""+d); } if(c1.getSelectedItem().equals("Cheque")) { d=ba*13/100; t3.setText(""+d); b2.setEnabled(false); } if(c1.getSelectedItem().equals("Credit Card")) { d=ba*8/100; t3.setText(""+d); b2.setEnabled(false); } b2.setEnabled(true); } else { if(c1.getSelectedItem().equals("Cash")) 26
    • { d=ba*10/100; t3.setText(""+d); } if(c1.getSelectedItem().equals("Cheque")) { d=ba*8/100; t3.setText(""+d); b2.setEnabled(false); } if(c1.getSelectedItem().equals("Credit Card")) { d=ba*5/100; t3.setText(""+d); b2.setEnabled(false); } } b2.setEnabled(true); } 1. Calculate Net Amount Button :na=ba-d; t4.setText(""+na); 2. Combo Box :if(c1.getSelectedItem().equals("Cheque")) { 27
    • t3.setText(null); t4.setText(null); b2.setEnabled(false); } if(c1.getSelectedItem().equals("Credit Card")) { t3.setText(null); t4.setText(null); b2.setEnabled(false);} 3. Exit Button :System.exit(0); 28
    • Experiment No. 14: Objective: Understanding the use of String library methods. Task: Develop an application to generate the jumbled string for given string. The jumbled string is obtained by converting each alternate character in uppercase. Public Class :Global variable declarations :String n1,n2; 1. Convert Button :n1=t1.getText(); n2=n1.toUpperCase(); t2.setText(""+n2); 2. Exit Button :Systemexit(0); 29
    • Experiment No. 15: Task: Develop an application to analyze the given string by counting the number ofvowels, consonants, digits and spaces etc. Public Class :String str; int vowels=0,digits=0,space=0,consonent=0; char ch; 1. Check Button :str=t1.getText(); for(int i = 0; i < str.length(); i ++) { ch = str.charAt(i); if(ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || ch == 'I' || ch == 'o' || ch == 'O' || ch == 'u' || ch == 'U') vowels ++; else if(Character.isDigit(ch)) digits ++; else if(Character.isSpace(ch)) space ++; else consonent++; t2.setText(""+vowels); t3.setText(""+consonent); t4.setText(""+space); t5.setText(""+digits); } 2. Exit Button :- System.exit(0); 30
    • PART 2 JAVA APPLICATION & DATABASE CONNECTIVITY Experiment No. 1: Objective: Understanding the Database Handling in JAVA application. Task: Design a Java application to display the records of the Emp table of MYORGdatabase designed in the MySQL. The Structure of Emp table is as follows. EName Char(40) Designation Char(30) Pay Decimal(9,2) City Char(40) 1. When Display record button is pressed, all the records are displayed. 2. When Calculate Total Pay button is pressed, the total pay is calculated and displayed in the Total Pay text box. 31
    • Public Class :Connection cn=null; Statement cmd=null; ResultSet rs=null; Connection :void est_connection() { try { Class.forName("com.mysql.jdbc.Driver"); Connection cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/pk","ro ot", "MKGM"); cmd=cn.createStatement(); } catch(Exception e) { JOptionPane.showMessageDialog(null,e.toString()); } } 1. Display Record :DefaultTableModel dtv=(DefaultTableModel) vtable.getModel(); try { est_connection(); rs=cmd.executeQuery("select * from empdetails"); while(rs.next()) { 32
    • dtv.addRow(new Object[]{rs.getString(1),rs.getString(2),rs.getString(3),rs.getString(4),} ); } } catch(Exception e) { JOptionPane.showMessageDialog(null,e.toString()); } } 2. Calculate Total Pay Button :{ try { est_connection(); rs=cmd.executeQuery("select sum(pay)from empdetails"); if(rs.next()) { t1.setText(""+rs.getInt(1)); } } catch(Exception e) { JOptionPane.showMessageDialog(null, e.toString()); } } 3. Exit Button :System.exit(0); 33
    • Experiment No. 2: Task: Design a fully featured Java application to navigate the records of the Emp table of MYORG database designed in the MySQL. 1. The First record is displayed when application is executed. 2. Records are displayed in Text boxes as per Navigation Buttons like First, Next etc are clicked. 3. Initially, Save and Cancel Button is disabled. When Add button is clicked, the Save and Cancel button is enabled and all the text boxes are cleared. The record is saved when Save button is pressed. 4. When Delete Button is clicked, the current record is deleted after getting confirmation from the user in Confirm dialog box. 5. When Modify button is clicked, user can edit the record. The modified record is saved when Save button is pressed. 34
    • Public Class Connection cn=null; Statement cmd=null; ResultSet rs=null; 1. Add Button :try { est_connection(); cmd.executeUpdate("insert into empdetails values ('"+t1.getText() + "','" + t2.getText() + "','" + t3.getText() + "','" + t4.getText() + "');"); JOptionPane.showMessageDialog(null,"Data inserted Successfully..."); } catch(Exception e) { JOptionPane.showMessageDialog(null,e.toString()); } 2. Delete Button :ResultSet rs1; try { est_connection(); cmd.executeUpdate("delete from empdetails where name='"+t1.getText() +"';"); JOptionPane.showMessageDialog(null,"Data deleted Successfully..."); } catch(Exception e) { JOptionPane.showMessageDialog(null,e.toString()); } 35
    • 3. Modify Button :try { est_connection(); { cmd.executeUpdate("update empdetails set Designation='" + t2.getText() + "',pay='" + t3.getText() + "',city='" + t4.getText() + " where Name='" + t1.getText() + "');"); JOptionPane.showMessageDialog(null,"Data updated Successfully..."); } } catch(Exception e) { JOptionPane.showMessageDialog(null,e.toString()); } 36
    • PART 3 MY SQL Experiment No. 1: Objective: Understanding the Database Handling through MySQL. Task: Create the following table and Answer the queries: Table Name :Client_master Name Type ---------------- --------------CLIENT_NO VARCHAR2(6) NAME VARCHAR2(20) ADDRESS1 VARCHAR2(30) ADDRESS2 VARCHAR2(30) CITY VARCHAR2(15) STATE VARCHAR2(15) PINCODE NUMBER(6) BAL_DUE NUMBER(10,2) Attributes ------------------Primary Key Not Null Data for client_master table CLIENT NO. C00001 C00002 C00003 C00004 C00005 C00006 CLIENT NAME CITY PINCODE STATE BAL_DUE Ivan Bayross VandanaSaitwal PramadaJaguste BasuNavindgi RaviShreedharan Rukmini Bombay Madras Bombay Bombay Delhi Bombay 400054 780001 400057 400056 100001 400050 Maharashtra Tamil Nadu Maharashtra Maharashtra 15000 0 5000 0 2000 0 37 Maharashtra
    • Table Name :Product_Master Name --------------PRODUCT_NO DESCRIPTION PROFIT_PERCENT UNIT_MEASURE QTY_ON_HAND REORDER_LVL SELL_PRICE COST_PRICE PRO.NO P00001 P03453 P06734 P07865 P07868 P07885 P07965 P07975 P08865 DESCRIPTION 1.44 Floppies Monitors Mouse 1.22 Floppies Keyboards CD Drive 540 HDD 1.44 Drive 1.22 Drive Type -----VARCHAR2(6) VARCHAR2(15) NUMBER(4,2) VARCHAR2(10) NUMBER(8) NUMBER(8) NUMBER(8,2) NUMBER(8,2) PROPER 5 6 5 5 2 2.5 4 5 5 Attributes -----------------Primary Key Not Null Not Null Not Null Not Null Not Null Not Null Not Null UNIT Piece Piece Piece Piece Piece Piece Piece Piece Piece QTY 100 10 20 100 10 10 10 10 2 REORDER_LVL 20 3 5 20 3 3 3 3 3 Table Name :Salesman_master Name ---------------SALESMAN_NO SALESMAN_NAME ADDRESS1 ADDRESS2 CITY PINCODE STATE SAL_AMT TGT_TO_GET YTD_SALES REMARKS Type ---------VARCHAR2(6) VARCHAR2(20) VARCHAR2(30) VARCHAR2(30) VARCHAR2(20) VARCHAR2(6) VARCHAR2(20) NUMBER(8,2) NUMBER(6,2) NUMBER(6,2) VARCHAR2(60) Attributes ------------Primary Key Not Null Not Null Not Null Not Null Not Null 38 SELLPRICE 525 12000 1050 525 3150 5250 8400 1050 1050 COST 500 11280 1000 500 3050 5100 8000 1000 1000
    • Data for Salesman Master: NO S00001 S00002 S00003 S00004 Name Kiran Manish Ravi Ashish Address1 A/14 65 P-7 A/5 Address2 Worli Nariman Bandra Juhu City Bombay Bombay Bombay Bombay Pincode 400002 400001 400032 400044 State MAH MAH MAH MAH Amt 3000 3000 3000 3500 Target 100 200 200 200 Sales 50 100 100 150 Remarks Good Good Good Good Table Name :sales_order Name --------------------S_ORDER_NO S_ORDER_DATE CLIENT_NO DELY_ADDR SALESMAN_NO DELY_TYPE BILLED_YN DELY_DATE ORDER_STATUS Type ---------VARCHAR2(6) DATE VARCHAR2(6) VARCHAR2(25) VARCHAR2(6) CHAR(1) CHAR(1) DATE VARCHAR2(10) Attributes ------------Primary Foreign Key client_no(client_master) Foreign Key salesman_no(salesman_master) Data for Sales Order: SONO SODATE CLIENTNO DELY_TYPE BILL Y/N SALESMAN DELY_DATE ORDER_STATUS ------------ ---------------------------- ---------------- -------------- ----------------- ------------------ -----------------------O19001 12-JAN-96 C00001 F N S00001 20-JAN-96 In Process O19002 25-JAN-96 C00002 P N S00002 27-JAN-96 Canceled O46865 18-FEB-96 C00003 F Y S00003 20-FEB-96 Fulfilled O19003 03-APR-96 C00001 F Y S00001 07-APR-96 Fulfilled O46866 20-MAY-96 C00004 P N S00002 22-MAY-96 Canceled O10008 24-MAY-96 C00005 F N S00004 26-MAY-96 In Process Table Name :sales_order_details Name -----------------S_ORDER_NO PRODUCT_NO Type -----VARCHAR2(6) VARCHAR2(6) QTY_ORDERED QTY_DISP PRODUCT_RATE NUMBER(8) NUMBER(8) NUMBER(10,2) Attributes ----------Primary Key Primary Key / Foreign Key references . Product_no of product_master table Table Name :challan_header Name -----------------CHALLAN_NO Start with ‘CH’. S_ORDER_NO sales_order table CHALLAN_DATE BILLED_YN Type --------VARCHAR2(6) VARCHAR2(6) DATE CHAR(1) Attributes ------------Primary Key / first two letters must Foreign Key references s_order_no of Not Null values(‘Y’,’N’),Default ‘N’. 39
    • S Q ql ueries Q.1 Find the name of all clients having ‘a’ as the second letter in their names. Ans. Select name from Client_master where name like ’_a%’; Q.2 Find out the clients who stay in a city whose second letter is ‘a’? Ans. Select name from Client_master where city like ’_a%’; Q.3 Find out the list of the client who stay in city ‘Bombay’ or city ‘Delhi’ or city ‘Madras’? Ans. Select name from Client_master where city in (‘Bombay’ ,’Delhi’ ,’Madras’); Q.4 List all the clients who are located in Bombay? Ans. Select name from Client_master where city like ‘Bombay’; Q.5 Print the list of clients whose bal_due are greater than value 10000? Ans. Select * from Client_master where bal_due>10000; Q.6 Find out the name of all the clients? Ans. Select name from Client_master; 40
    • Q.7 Print the entire Client_master table? Ans. Select * from Client_master; Q.8 Retrieve the list of names and cities of all the clients? Ans. Select name,city from Client_master; Q.9 Count the total number of orders? Ans. select count(reorder_lvl) from sales_order; Q.10 Calculate the average price of all the product? Ans. select avg(cost_price) from product_master; Q.11 Calculate the minimum price of all the product? Ans. select min (sell_price) from product_master; Q.12 Determine the maximum and minimum product prices. Rename the title as max_price and min_price respectively? Ans. Select max(sell_price) as max_price, min(sell_price) as min_price from product_master; Q.13 Count the number of products having price greater than or equal to 1500? Ans. select count(*) cost_price>=1500; from 41 product_master where
    • Q.14 Find all the products whose qty_on_hand is less than reorder level? Ans.select description from qty_on_hand< reorder_level; product_master where Q.15 Print the description for each product? Ans. . Select description from product_master group by description ; Q.16 Find the value of each product sold? Ans.select description, sum(s.qty_disp+product_rate) ”total sold value” from product_master p, sales_order_details s where p.product_no,s.product_no group by p.description; Q.17 Calculate the average qty sold for each client that has a maximum order value of 15000.00? Ans. select c.clent_no, c.client_name, avg(o.qty_disp) ”avg product” from client_master c, sales_order s, sales_order_details o where s.s_order_no = o.s_order_no and c.client_no=s.client_no group by c.client_no,c.client_name having max(o.qty_ordered*o.product_rate)>15000; Q.18 Find out the total sales amount receiveble for the month of jan. it will be the sum total of all the billed orders for the month? 42
    • Ans.select o.s_order_no, sum(o.qty_ordered*o.product_rate) ”sum product” from sales_ order s, sales_order_details o where s.s_order_no=o.s_order_no and s.billed_yn like “y” and s.s_order_date like ‘%-jan-%’ group by o.s_order_no; Q.19 Print the information of product_master, sales_order_detail table in the following format for all the records :- description total sales for the product Ans. select p.description,sum(s.qty_ordered*s.product_rate) from product_master p,sales_order_details s where p.product_no=s.product_no; Q.20 Change the delivery date of order number ‘010008’ to 16-08-96? Ans.update sales_order set dely_date=’1996-08-16’ where s_order_no=’O10008’ ; Q.21 Change the bal_due of client_no ‘c00001’ to 1000? Ans. update Client_master set client_no =’C0001’ ; bal_due=1000 where Q.22 Change the cost price of ‘1.22 Floppy Drive’ to Rs. 950.00? Ans. update product_master set cost_price=’950.00’ where description=’1.22 Floppies’; 43
    • Q.23 Find out the maximum product rate for each product? Ans.select description,max(cost_price) from product_master Group by product_no; Q.24 Display the order number and day on which client placed their order? Ans.select s_order_no, dayname(s_order_date) from sales_order group by client_no; Q.25 Display the month(in alphabets) and date when the order must be delivered? Ans. select sales_order; monthname(dely_date),dely_date 44 from
    • 45