ELECTRICITY BILLING SYSTEM

ELECTRICITY BILLING SYSTEM

Create a electricity biilling system using JAVA

#knowledge #stream #blog
you can find the full source code for the project below.


A - Below is the source code of the project.

B - Create separate class files for every class.

C - Copy the code of one class (ex: login.java) and paste it in Login class file, do it for every class.

1 - Create your first class with name 'conn' and paste the code


package Electricity;

import java.sql.*;  

//knowledgestreams.blogspot.com

public class conn{
    Connection c;
    Statement s;
    public conn(){  
        try{  
            Class.forName("com.mysql.jdbc.Driver");  
            c =DriverManager.getConnection("jdbc:mysql:///project","root","");    
            s =c.createStatement();  
        }catch(Exception e){ 
            System.out.println(e);
        }  
    }  
}  
//knowledgestreams.blogspot.com
//knowledgestreams.blogspot.com

2 - Create next class with name 'Splash' and paste the code below in it. This is also our Main Frame of the project.

package Electricity; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class splash { public static void main(String[] args){ fframe f1 = new fframe(); f1.setVisible(true); int i; int x=1; for(i=2; i<=600; i+=4, x+=1){ f1.setLocation(800 - ((i+x)/2), 500 - (i/2)); f1.setSize(i+x,i); try{ Thread.sleep(10); }catch(Exception e){} } } } class fframe extends JFrame implements Runnable{ Thread t1; fframe(){ super("Electricity Billing System"); setLayout(new FlowLayout()); ImageIcon c1 = new ImageIcon(ClassLoader.getSystemResource("icon/elect.jpg")); Image i1 = c1.getImage().getScaledInstance(730, 550,Image.SCALE_DEFAULT); ImageIcon i2 = new ImageIcon(i1); JLabel l1 = new JLabel(i2); add(l1); t1 = new Thread(this); t1.start(); } public void run(){ try{ Thread.sleep(7000); this.setVisible(false); Login l = new Login(); l.setVisible(true); }catch(Exception e){ e.printStackTrace(); } } }

//knowledgestreams.blogspot.com https://knowledgestreams.blogspot.com/

3 - Create next class with name 'Login'.

package Electricity; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.sql.*; public class Login extends JFrame implements ActionListener{ JLabel l1,l2,l3; JTextField tf1; JPasswordField pf2; JButton b1,b2; JPanel p1,p2,p3,p4; Login(){ super("Login Page"); l1 = new JLabel("Username"); l2 = new JLabel("Password"); tf1 = new JTextField(15); pf2 = new JPasswordField(15); ImageIcon ic1 = new ImageIcon(ClassLoader.getSystemResource("icon/login.png")); Image i1 = ic1.getImage().getScaledInstance(16, 16,Image.SCALE_DEFAULT); b1 = new JButton("Login", new ImageIcon(i1)); ImageIcon ic2 = new ImageIcon(ClassLoader.getSystemResource("icon/cancel.jpg")); Image i2 = ic2.getImage().getScaledInstance(16, 16,Image.SCALE_DEFAULT); b2 = new JButton("Cancel",new ImageIcon(i2)); b1.addActionListener(this); b2.addActionListener(this); ImageIcon ic3 = new ImageIcon(ClassLoader.getSystemResource("icon/pop.png")); Image i3 = ic3.getImage().getScaledInstance(128, 128,Image.SCALE_DEFAULT); ImageIcon icc3 = new ImageIcon(i3); l3 = new JLabel(icc3); setLayout(new BorderLayout()); p1 = new JPanel(); p2 = new JPanel(); p3 = new JPanel(); p4 = new JPanel(); knowledgestreams.blogspot.com add(l3,BorderLayout.WEST); p2.add(l1); p2.add(tf1); p2.add(l2); p2.add(pf2); add(p2,BorderLayout.CENTER); p4.add(b1); p4.add(b2); add(p4,BorderLayout.SOUTH); p2.setBackground(Color.WHITE); p4.setBackground(Color.WHITE); setSize(440,250); setLocation(600,400); setVisible(true); //knowledgestreams.blogspot.com } public void actionPerformed(ActionEvent ae){ try{ conn c1 = new conn(); String a = tf1.getText(); String b = pf2.getText(); String q = "select * from login where username = '"+a+"' and password = '"+b+"'"; ResultSet rs = c1.s.executeQuery(q); if(rs.next()){ new Project().setVisible(true); this.setVisible(false); }else{ JOptionPane.showMessageDialog(null, "Invalid login"); setVisible(false); } }catch(Exception e){ e.printStackTrace(); System.out.println("error: "+e); } } public static void main(String[] args){ new Login().setVisible(true); } }

//knowledgestreams.blogspot.com
4 - Create next class with name 'Project' and paste the code inside the class.

package Electricity; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Project extends JFrame implements ActionListener{ Project(){ super("Electricity Billing System"); setSize(1920,1030); /* Adding background image */ ImageIcon ic = new ImageIcon(ClassLoader.getSystemResource("icon/elect1.jpg")); Image i3 = ic.getImage().getScaledInstance(1900, 950,Image.SCALE_DEFAULT); ImageIcon icc3 = new ImageIcon(i3); JLabel l1 = new JLabel(icc3); add(l1); /* First Column */ JMenuBar mb = new JMenuBar(); JMenu master = new JMenu("Master"); JMenuItem m1 = new JMenuItem("New Customer"); JMenuItem m2 = new JMenuItem("Customer Details"); JMenuItem m3 = new JMenuItem("Deposit Details"); master.setForeground(Color.BLUE); /* ---- Customer Details ---- */ m1.setFont(new Font("monospaced",Font.PLAIN,12)); ImageIcon icon1 = new ImageIcon(ClassLoader.getSystemResource("icon/icon1.png")); Image image1 = icon1.getImage().getScaledInstance(20, 20,Image.SCALE_DEFAULT); m1.setIcon(new ImageIcon(image1)); m1.setMnemonic('D'); m1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, ActionEvent.CTRL_MASK)); m1.setBackground(Color.WHITE); /* ---- Meter Details ---- */ m2.setFont(new Font("monospaced",Font.PLAIN,12)); ImageIcon icon2 = new ImageIcon(ClassLoader.getSystemResource("icon/icon2.png")); Image image2 = icon2.getImage().getScaledInstance(20, 20,Image.SCALE_DEFAULT); m2.setIcon(new ImageIcon(image2)); m2.setMnemonic('M'); m2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK)); m2.setBackground(Color.WHITE); /* ---- Deposit Details ----- */ m3.setFont(new Font("monospaced",Font.PLAIN,12)); ImageIcon icon3 = new ImageIcon(ClassLoader.getSystemResource("icon/icon3.png")); Image image3 = icon3.getImage().getScaledInstance(20, 20,Image.SCALE_DEFAULT); m3.setIcon(new ImageIcon(image3)); m3.setMnemonic('N'); m3.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK)); m3.setBackground(Color.WHITE); m1.addActionListener(this); m2.addActionListener(this); m3.addActionListener(this); // -------------------------------------------------------------------------------------------- //knowledgestreams.blogspot.com
/* Second Column */ JMenu user = new JMenu("User"); JMenuItem u1 = new JMenuItem("Pay Bill"); JMenuItem u2 = new JMenuItem("Calculate Bill"); JMenuItem u3 = new JMenuItem("Last Bill"); user.setForeground(Color.RED); /* ---- Pay Bill ---- */ u1.setFont(new Font("monospaced",Font.PLAIN,12)); ImageIcon icon4 = new ImageIcon(ClassLoader.getSystemResource("icon/icon4.png")); Image image4 = icon4.getImage().getScaledInstance(20, 20,Image.SCALE_DEFAULT); u1.setIcon(new ImageIcon(image4)); u1.setMnemonic('P'); u1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK)); u1.setBackground(Color.WHITE); /* ---- Bill Details ---- */ u2.setFont(new Font("monospaced",Font.PLAIN,12)); ImageIcon icon5 = new ImageIcon(ClassLoader.getSystemResource("icon/icon5.png")); Image image5 = icon5.getImage().getScaledInstance(20, 20,Image.SCALE_DEFAULT); u2.setIcon(new ImageIcon(image5)); u2.setMnemonic('B'); u2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK)); u2.setBackground(Color.WHITE); /* ---- Last Bill ----*/ u3.setFont(new Font("monospaced",Font.PLAIN,12)); ImageIcon icon6 = new ImageIcon(ClassLoader.getSystemResource("icon/icon6.png")); Image image6 = icon6.getImage().getScaledInstance(20, 20,Image.SCALE_DEFAULT); u3.setIcon(new ImageIcon(image6)); u3.setMnemonic('L'); u3.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, ActionEvent.CTRL_MASK)); u3.setBackground(Color.WHITE); u1.addActionListener(this); u2.addActionListener(this); u3.addActionListener(this); // --------------------------------------------------------------------------------------------- /* Third Column*/ JMenu report = new JMenu("Report"); JMenuItem r1 = new JMenuItem("Generate Bill"); report.setForeground(Color.BLUE); /* ---- Report ---- */ r1.setFont(new Font("monospaced",Font.PLAIN,12)); ImageIcon icon7 = new ImageIcon(ClassLoader.getSystemResource("icon/icon7.png")); Image image7 = icon7.getImage().getScaledInstance(20, 20,Image.SCALE_DEFAULT); r1.setIcon(new ImageIcon(image7)); r1.setMnemonic('R'); r1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK)); r1.setBackground(Color.WHITE); r1.addActionListener(this); // ----------------------------------------------------------------------------------------------- /* Fourth Column*/ JMenu utility = new JMenu("Utility"); JMenuItem ut1 = new JMenuItem("Notepad"); JMenuItem ut2 = new JMenuItem("Calculator"); JMenuItem ut3 = new JMenuItem("Web Browser"); utility.setForeground(Color.RED); /* ---- Calender ---- */ ut1.setFont(new Font("monospaced",Font.PLAIN,12)); ImageIcon icon8 = new ImageIcon(ClassLoader.getSystemResource("icon/icon12.png")); Image image8 = icon8.getImage().getScaledInstance(20, 20,Image.SCALE_DEFAULT); ut1.setIcon(new ImageIcon(image8)); ut1.setMnemonic('C'); ut1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK)); ut1.setBackground(Color.WHITE); /* ---- Calculator ---- */ ut2.setFont(new Font("monospaced",Font.PLAIN,12)); ImageIcon icon9 = new ImageIcon(ClassLoader.getSystemResource("icon/icon9.png")); Image image9 = icon9.getImage().getScaledInstance(20, 20,Image.SCALE_DEFAULT); ut2.setIcon(new ImageIcon(image9)); ut2.setMnemonic('X'); ut2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK)); ut2.setBackground(Color.WHITE); /* ---- Web Browser ---- */ ut3.setFont(new Font("monospaced",Font.PLAIN,12)); ImageIcon icon10 = new ImageIcon(ClassLoader.getSystemResource("icon/icon10.png")); Image image10 = icon10.getImage().getScaledInstance(20, 20,Image.SCALE_DEFAULT); ut3.setIcon(new ImageIcon(image10)); ut3.setMnemonic('W'); ut3.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, ActionEvent.CTRL_MASK)); ut3.setBackground(Color.WHITE); ut1.addActionListener(this); ut2.addActionListener(this); ut3.addActionListener(this); // --------------------------------------------------------------------------------------- /*Fifth Column */ JMenu exit = new JMenu("Exit"); JMenuItem ex = new JMenuItem("Exit"); exit.setForeground(Color.BLUE); /* ---- Exit ---- */ ex.setFont(new Font("monospaced",Font.PLAIN,12)); ImageIcon icon11 = new ImageIcon(ClassLoader.getSystemResource("icon/icon11.png")); Image image11 = icon11.getImage().getScaledInstance(20, 20,Image.SCALE_DEFAULT); ex.setIcon(new ImageIcon(image11)); ex.setMnemonic('Z'); ex.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, ActionEvent.CTRL_MASK)); ex.setBackground(Color.WHITE); ex.addActionListener(this); // --------------------------------------------------------------------------------------------- master.add(m1); master.add(m2); master.add(m3); user.add(u1); user.add(u2); user.add(u3); report.add(r1); utility.add(ut1); utility.add(ut2); utility.add(ut3); exit.add(ex); mb.add(master); mb.add(user); mb.add(report); mb.add(utility); mb.add(exit); setJMenuBar(mb); setFont(new Font("Senserif",Font.BOLD,16)); setLayout(new FlowLayout()); setVisible(false); } public void actionPerformed(ActionEvent ae){ String msg = ae.getActionCommand(); if(msg.equals("Customer Details")){ new customer_details().setVisible(true); }else if(msg.equals("New Customer")){ new new_customer().setVisible(true); }else if(msg.equals("Calculate Bill")){ new calculate_bill().setVisible(true); }else if(msg.equals("Pay Bill")){ new pay_bill().setVisible(true); }else if(msg.equals("Notepad")){ try{ Runtime.getRuntime().exec("notepad.exe"); }catch(Exception e){ } }else if(msg.equals("Calculator")){ try{ Runtime.getRuntime().exec("calc.exe"); }catch(Exception e){ } }else if(msg.equals("Web Browser")){ try{ Runtime.getRuntime().exec("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"); }catch(Exception e){ } }else if(msg.equals("Exit")){ System.exit(0); }else if(msg.equals("Generate Bill")){ new generate_bill().setVisible(true); } } public static void main(String[] args){ new Project().setVisible(true); } }

knowledge streams blog spot com

5 - Create next class with name 'new_customer'.


package Electricity; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.sql.*; public class new_customer extends JFrame implements ActionListener{ JLabel l1,l2,l3,l4,l5,l6,l7,l8; JTextField t1,t2,t3,t4,t5,t6,t7; JButton b1,b2; new_customer(){ setLocation(350,200); setSize(650,600); JPanel p = new JPanel(); p.setLayout(new GridLayout(9,2,10,10)); p.setBackground(Color.WHITE); l1 = new JLabel("Name"); t1 = new JTextField(); p.add(l1); p.add(t1); l2 = new JLabel("Meter No"); t2 = new JTextField(); p.add(l2); p.add(t2); l3 = new JLabel("Address"); t3 = new JTextField(); p.add(l3); p.add(t3); l4 = new JLabel("State"); t4 = new JTextField(); p.add(l4); p.add(t4); l5 = new JLabel("City"); t5 = new JTextField(); p.add(l5); p.add(t5); l6 = new JLabel("Email"); t6 = new JTextField(); p.add(l6); p.add(t6); l7 = new JLabel("Phone Number"); t7 = new JTextField(); p.add(l7); p.add(t7); b1 = new JButton("Submit"); b2 = new JButton("Cancel"); b1.setBackground(Color.BLACK); b1.setForeground(Color.WHITE); b2.setBackground(Color.BLACK); b2.setForeground(Color.WHITE); p.add(b1); p.add(b2); setLayout(new BorderLayout()); add(p,"Center"); ImageIcon ic1 = new ImageIcon(ClassLoader.getSystemResource("icon/hicon1.jpg")); Image i3 = ic1.getImage().getScaledInstance(150, 300,Image.SCALE_DEFAULT); ImageIcon ic2 = new ImageIcon(i3); l8 = new JLabel(ic2); add(l8,"West"); //for changing the color of the whole getContentPane().setBackground(Color.WHITE); b1.addActionListener(this); b2.addActionListener(this); } public void actionPerformed(ActionEvent ae){ String a = t1.getText(); String c = t2.getText(); String d = t3.getText(); String e = t4.getText(); String f = t5.getText(); String g = t6.getText(); String h = t7.getText(); String q1 = "insert into emp values('"+a+"','"+c+"','"+d+"','"+e+"','"+f+"','"+g+"','"+h+"')"; try{ conn c1 = new conn(); c1.s.executeUpdate(q1); JOptionPane.showMessageDialog(null,"Employee Created"); this.setVisible(false); }catch(Exception ex){ ex.printStackTrace(); } } public static void main(String[] args){ new new_customer().setVisible(true); } }


6 - Create next class with name 'customer_details'.
#knowledgestreams.blogspot.com

//knowledge streams blog spot

package Electricity; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.sql.*; public class customer_details extends JFrame implements ActionListener{ JTable t1; JButton b1; String x[] = {"Emp Name","Meter No","Address","State","City","Email","Phone"}; String y[][] = new String[20][8]; int i=0, j=0; customer_details(){ super("Customer Details"); setSize(1200,650); setLocation(200,200); try{ conn c1 = new conn(); String s1 = "select * from emp"; ResultSet rs = c1.s.executeQuery(s1); while(rs.next()){ y[i][j++]=rs.getString("name"); y[i][j++]=rs.getString("meter_number"); y[i][j++]=rs.getString("address"); y[i][j++]=rs.getString("state"); y[i][j++]=rs.getString("city"); y[i][j++]=rs.getString("email"); y[i][j++]=rs.getString("phone"); i++; j=0; } t1 = new JTable(y,x); }catch(Exception e){ e.printStackTrace(); } b1 = new JButton("Print"); add(b1,"South"); JScrollPane sp = new JScrollPane(t1); add(sp); b1.addActionListener(this); } public void actionPerformed(ActionEvent ae){ try{ t1.print(); }catch(Exception e){} } public static void main(String[] args){ new customer_details().setVisible(true); } }


7 - Create next class with name 'calculate_bill'.

package Electricity; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.sql.*; public class calculate_bill extends JFrame implements ActionListener{ JLabel l1,l2,l3,l4,l5; JTextField t1; Choice c1,c2; JButton b1,b2; JPanel p; calculate_bill(){ p = new JPanel(); p.setLayout(new GridLayout(4,2,30,30)); p.setBackground(Color.WHITE); l1 = new JLabel("Calculate Electricity Bill"); l2 = new JLabel("Meter No"); l3 = new JLabel("Units Cosumed"); l5 = new JLabel("Month"); t1 = new JTextField(); c1 = new Choice(); c1.add("1001"); c1.add("1002"); c1.add("1003"); c1.add("1004"); c1.add("1005"); c1.add("1006"); c1.add("1007"); c1.add("1008"); c1.add("1009"); c1.add("1010"); c2 = new Choice(); c2.add("January"); c2.add("February"); c2.add("March"); c2.add("April"); c2.add("May"); c2.add("June"); c2.add("July"); c2.add("August"); c2.add("September"); c2.add("October"); c2.add("November"); c2.add("December"); b1 = new JButton("Submit"); b2 = new JButton("Cancel"); b1.setBackground(Color.BLACK); b1.setForeground(Color.WHITE); b2.setBackground(Color.BLACK); b2.setForeground(Color.WHITE); ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("icon/hicon2.jpg")); Image i2 = i1.getImage().getScaledInstance(180, 270,Image.SCALE_DEFAULT); ImageIcon i3 = new ImageIcon(i2); l4 = new JLabel(i3); l1.setFont(new Font("Senserif",Font.PLAIN,26)); //Move the label to center l1.setHorizontalAlignment(JLabel.CENTER); p.add(l2); p.add(c1); p.add(l5); p.add(c2); p.add(l3); p.add(t1); p.add(b1); p.add(b2); setLayout(new BorderLayout(30,30)); add(l1,"North"); add(p,"Center"); add(l4,"West"); //knowledgestreams.blogspot.com b1.addActionListener(this); b2.addActionListener(this); getContentPane().setBackground(Color.WHITE); setSize(650,500); setLocation(350,220); } public void actionPerformed(ActionEvent ae){ String a = c1.getSelectedItem(); String b = t1.getText(); String c = c2.getSelectedItem(); int p1 = Integer.parseInt(b); int p2 = p1*7; int p3 = p2+50+12+102+20+50; String q = "insert into bill values('"+a+"','"+c+"','"+b+"','"+p3+"')"; try{ conn c1 = new conn(); c1.s.executeUpdate(q); JOptionPane.showMessageDialog(null,"Bill Updated"); }catch(Exception aee){ aee.printStackTrace(); } } public static void main(String[] args){ new calculate_bill().setVisible(true); } }



8 - Create next class with name 'pay_bill'.

package Electricity; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class pay_bill extends JFrame{ pay_bill(){ JEditorPane j = new JEditorPane(); j.setEditable(false); try { j.setPage("https://paytm.com/electricity-bill-payment"); }catch (Exception e) { j.setContentType("text/html"); j.setText("<html>Could not load</html>"); } JScrollPane scrollPane = new JScrollPane(j); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); getContentPane().add(scrollPane); setPreferredSize(new Dimension(800,600)); setSize(800,800); setLocation(250,120); setVisible(true); } public static void main(String[] args){ new pay_bill().setVisible(true); } }
//knowledgestreams.blogspot.com

9 - Create next class with name 'generate_bill'.


package Electricity; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.sql.*; public class generate_bill extends JFrame implements ActionListener{ JLabel l1; JTextArea t1; JButton b1; Choice c1,c2; JPanel p1; generate_bill(){ setSize(500,900); setLayout(new BorderLayout()); p1 = new JPanel(); l1 = new JLabel("Generate Bill"); c1 = new Choice(); c2 = new Choice(); //knowledgestreams.blogspot.com
c1.add("1001"); c1.add("1002"); c1.add("1003"); c1.add("1004"); c1.add("1005"); c1.add("1006"); c1.add("1007"); c1.add("1008"); c1.add("1009"); c1.add("1010"); c2.add("January"); c2.add("February"); c2.add("March"); c2.add("April"); c2.add("May"); c2.add("June"); c2.add("July"); c2.add("August"); c2.add("September"); c2.add("October"); c2.add("November"); c2.add("December"); t1 = new JTextArea(50,15); JScrollPane jsp = new JScrollPane(t1); t1.setFont(new Font("Senserif",Font.ITALIC,18)); b1 = new JButton("Generate Bill"); p1.add(l1); p1.add(c1); p1.add(c2); add(p1,"North"); add(jsp,"Center"); add(b1,"South"); b1.addActionListener(this); //knowledgestreams.blogspot.com setLocation(350,40); } public void actionPerformed(ActionEvent ae){ try{ conn c = new conn(); String month = c2.getSelectedItem(); t1.setText("\abc\nELECTRICITY BILL FOR THE MONTH OF "+month+" ,2018\n\n\n"); ResultSet rs = c.s.executeQuery("select * from emp where meter_number="+c1.getSelectedItem()); if(rs.next()){ t1.append("\n Customer Name:"+rs.getString("name")); t1.append("\n Meter Number: "+rs.getString("meter_number")); t1.append("\n Address: "+rs.getString("address")); t1.append("\n State: "+rs.getString("state")); t1.append("\n City: "+rs.getString("city")); t1.append("\n Email: "+rs.getString("email")); t1.append("\n Phone Number "+rs.getString("phone")); t1.append("\n-------------------------------------------------------------"); t1.append("\n"); } rs = c.s.executeQuery("select * from tax"); if(rs.next()){ t1.append("\n Meter Location:"+rs.getString("meter_location")); t1.append("\n Meter Type: "+rs.getString("meter_type")); t1.append("\n Phase Code: "+rs.getString("phase_code")); t1.append("\n Bill Type: "+rs.getString("bill_type")); t1.append("\n Days: "+rs.getString("days")); t1.append("\n"); t1.append("---------------------------------------------------------------"); t1.append("\n\n"); t1.append("\n Meter Rent:\t\t"+rs.getString("meter_rent")); t1.append("\n MCB Rent: \t\t"+rs.getString("mcb_rent")); t1.append("\n Service Tax:\t"+rs.getString("service_rent")); t1.append("\n GST@9%:\t\t"+rs.getString("gst")); t1.append("\n"); } rs = c.s.executeQuery("select * from bill where meter_number="+c1.getSelectedItem()); if(rs.next()){ t1.append("\n Current Month :\t"+rs.getString("month")); t1.append("\n Units Consumed:\t"+rs.getString("units")); t1.append("\n Total Charges :\t"+rs.getString("amount")); t1.append("\n---------------------------------------------------------------"); t1.append("\n TOTAL PAYABLE :\t"+rs.getString("amount")); } //knowledgestreams.blogspot.com
}catch(Exception e){ e.printStackTrace(); } } public static void main(String[] args){ new generate_bill().setVisible(true); } }

10- Create next class with name "Last Bill"


package Electricity; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.sql.*; public class LastBill extends JFrame implements ActionListener{ JLabel l1; JTextArea t1; JButton b1; Choice c1; JPanel p1; LastBill(){ setSize(500,900); setLayout(new BorderLayout()); p1 = new JPanel(); l1 = new JLabel("Generate Bill"); c1 = new Choice(); c1.add("1001"); c1.add("1002"); c1.add("1003"); c1.add("1004"); c1.add("1005"); c1.add("1006"); c1.add("1007"); c1.add("1008"); c1.add("1009"); c1.add("1010"); t1 = new JTextArea(50,15); JScrollPane jsp = new JScrollPane(t1); t1.setFont(new Font("Senserif",Font.ITALIC,18)); b1 = new JButton("Generate Bill"); p1.add(l1); p1.add(c1); add(p1,"North"); add(jsp,"Center"); add(b1,"South"); b1.addActionListener(this); setLocation(350,40); } public void actionPerformed(ActionEvent ae){ try{ conn c = new conn(); ResultSet rs = c.s.executeQuery("select * from emp where meter_number="+c1.getSelectedItem()); if(rs.next()){ t1.append("\n Customer Name:"+rs.getString("name")); t1.append("\n Meter Number: "+rs.getString("meter_number")); t1.append("\n Address: "+rs.getString("address")); t1.append("\n State: "+rs.getString("state")); t1.append("\n City: "+rs.getString("city")); t1.append("\n Email: "+rs.getString("email")); t1.append("\n Phone Number "+rs.getString("phone")); t1.append("\n-------------------------------------------------------------"); t1.append("\n"); } t1.append("Details of the Last Bills\n\n\n"); rs = c.s.executeQuery("select * from bill where meter_number="+c1.getSelectedItem()); while(rs.next()){ t1.append(" "+ rs.getString("month") + " " +rs.getString("amount") + "\n"); } }catch(Exception e){ e.printStackTrace(); } } public static void main(String[] args){ new LastBill().setVisible(true); } }




#java #electricity #bill #code


Free source code for java project on electricity billing system.

Python code for converting colored image to black and white

Python code for converting colored image to black and white

Libraries used: PIL for python
IDE Used: Spyder
Tutorial video link: Click Here

https://knowledgestreams.blogspot.com/

knowledge streams blog spot dot com free knowledge blog. download free source codes for python and java and other free stuff.


from PIL import Image
open_image = Image.open("adress of the pictures")
open_image.show()
convert_to_blackandwhite= open_image.convert("L")
convert_to_blackandwhite.show()






knowledge streams blog spot dot com free knowledge blog. download free source codes for python and java and other free stuff.


Q: How to Install PIL??

A1: pip install PIL
A2: pip install pillow

#Python #beginner #source_code #image #convert

My Hobby Essay In Urdu

My Hobby Essay In Urdu 

Farigh auqat ko kaam mein lanay ke liye insan ko koi na koi mashghala zaroor ikhtyar karna chahiye maslan baghbani, parhna likhna, ticket jama karna. sikay jama karna, tasweer banana, tasweerain jama karna wagera. Mera mashghala ticket jama karna hai. Main tarah tarah ke ticket jama karta raha hon aur free time yani farigh waqt mein mere album mein tarteeb se lagata rehta hon. Is tarah ke lamhat bohat achi tarah guzar jatay hain.

knowledge streams blog spot dot com free knowledge blog. download free source codes for python and java and other free stuff.



Ticket jama karna yani collecting ticket mera pasandida mashghala hai. Is liye main ne kabhi koshish nahin ki ke jald az jald bohat sare ticket khareed loun aur album bhar loun. Khareed kar aik hi baar bohat se ticket hasil kar laina mashghalay ke adab ke khilaf hai. Is ka taqaza hai ke aik ticket ke husool ke liye mehnat ki jaye. Chunachay mein ticket khaton se utarta hon ya dusron se tickets ka tabadla karta hon. Is se jama karne mein waqt tou lagta hai magar maza bhi ata hai.

knowledge streams blog spot dot com free knowledge blog. download free source codes for python and java and other free stuff.


Mere pas bari khubsurat album hai. Is par har mulk ke ticket lagane ke liye alag alag safhay hain. Main un safhon par mukhtalif mulkon ke naye naye ticket lagata rehta hon. Ab mere paas itnay zayada ticket ho chukay hain ke mujhe kam az kam 2 album aur khareednay ki zaroorat hai.

knowledge streams blog spot dot com free knowledge blog. download free source codes for python and java and other free stuff.

Ticket jama karne ka mashghala bohat mufeed bhi hai. Is se sirf farigh auqat hi achay nahin guzartay balkeh is ke khuch amli faide bhi hain. Tickets ke mushahiday se mukhtalif mumalik ki shakhsiyat, muqamat wagera ke bare mein maloomat hasil hoti hain aur wahan ke awam aur hukmaranon ke bare mein bhi bohat khuch maloom hota hai kyoun ke tickets wali tasaweer is silsile mein rehnumai karti hain. Un ke nazdeek mukhtalif mulkon ke qaumi dinon, awami taqreebat aur yadgar ke baray mein maloomat hasil hoti hain. Main tou dusron ko bhi mashwara doun ga ke wo farigh waqt ke liye koi na koi mashghala zaroor ikhtyar karain.

knowledge streams blog spot dot com free knowledge blog. download free source codes for python and java and other free stuff.


#urdu #hobby #essay #mazmon #ticket #mufeed  #urdu

knowledge streams blog spot dot com free knowledge blog. download free source codes for python and java and other free stuff.



The Jupyter Notebook

The Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and narrative text. Uses include: data cleaning and transformation, numerical simulation, statistical modeling, data visualization, machine learning, and much more.

knowledge streams blog spot dot com free knowledge blog. download free source codes for python and java and other free stuff.











Language of choice

Jupyter supports over 40 programming languages, including Python, R, Julia, and Scala.

Share notebooks

Notebooks can be shared with others using email, Dropbox, GitHub and the Jupyter Notebook Viewer.

Interactive output

Your code can produce rich, interactive output: HTML, images, videos, LaTeX, and custom MIME types.

Big data integration

Leverage big data tools, such as Apache Spark, from Python, R and Scala. Explore that same data with pandas, scikit-learn, ggplot2, TensorFlow.


Centralized deployment

Deploy the Jupyter Notebook to thousands of users in your organization on centralized infrastructure on- or off-site.

Container friendly

Use Docker and Kubernetes to scale your deployment, isolate user processes, and simplify software installation.
knowledge streams blog spot dot com free knowledge blog. download free source codes for python and java and other free stuff.

Code meets data

Deploy the Notebook next to your data to provide unified software management and data access within your organization.

Pluggable authentication

Manage users and authentication with PAM, OAuth or integrate with your own directory service system.
                    

JupyterLab 1.0: Jupyter’s Next-Generation Notebook Interface

knowledge streams blog spot dot com free knowledge blog. download free source codes for python and java and other free stuff.

JupyterLab is a web-based interactive development environment for Jupyter notebooks, code, and data. JupyterLab is flexible: configure and arrange the user interface to support a wide range of workflows in data science, scientific computing, and machine learning. JupyterLab is extensible and modular: write plugins that add new components and integrate with existing ones.


#Python #Jupyter #programming #Artificialintelligence

Types of Links on Switches

Types of Links  that can be created on a Network Switch


Video Tutorial link given at end

ACCESS LINKS

Access Links are the most common type of links on any VLAN switch. All network hosts connect to the switch's Access Links in order to gain access to the local network. These links are your ordinary ports found on every switch, but configured in a special way, so you are able to plug a computer into them and access your network.

knowledge streams blog spot dot com free knowledge blog. download free source codes for python and java and other free stuff.

We must note that the 'Access Link' term describes a configured port - this means that the ports above can be configured as the second type of VLAN links - Trunk Links. What we are showing here is what's usually configured as an Access Link port in 95% of all switches. Depending on your needs, you might require to configure the first port (top left corner) as a Trunk Link, in which case, it is obviously not called a Access Link port anymore, but a Trunk Link!
When configuring ports on a switch to act as Access Links, we usually configure only one VLAN per port, that is, the VLAN our device will be allowed to access. If you recall the diagram below which was also present during the introduction of the VLAN concept, you'll see that each PC is assigned to a specific port:

TRUNK LINKS

What we've seen so far is a switch port configured to carry only one VLAN, that is, an Access Link port. There is, however, one more type of port configuration which we mentioned in the introductory section on this page - the Trunk Link.

knowledge streams blog spot dot com free knowledge blog. download free source codes for python and java and other free stuff.

A Trunk Link, or 'Trunk' is a port configured to carry packets for any VLAN. These type of ports are usually found in connections between switches. These links require the ability to carry packets from all available VLANs because VLANs span over multiple switches.
The diagram below shows multiple switches connected throughout a network and the Trunk Links are marked in purple colour to help you identify them:



As you can see in our diagram, our switches connect to the network backbone via the Trunk Links. This allows all VLANs created in our network to propagate throughout the whole network. Now in the unlikely event of Trunk Link failure on one of our switches, the devices connected to that switch's ports would be isolated from the rest of the network, allowing only ports on that switch, belonging to the same VLAN, to communicate with each other.
So now that we have an idea of what Trunk Links are and their purpose, let's take a look at an actual switch to identify a possible Trunk Link:

knowledge streams blog spot dot com free knowledge blog. download free source codes for python and java and other free stuff.




As we noted with the explanation of Access Link ports, the term 'Trunk Link' describes a configured port. In this case, the Gigabit ports are usually configured as Trunk Links, connecting the switch to the network backbone at the speed of 1 Gigabit, while the Access Link ports connect at 100Mbits.
In addition, we should note that for a port or link to operate as a Trunk Link, it is imperative that it runs at speeds of 100Mbit or greater. A port running at speeds of 10Mbit's cannot operate as a Trunk Link and this is logical because a Trunk Link is always used to connect to the network backbone, which must operate at speeds greater than most Access Links!

knowledge streams blog spot dot com free knowledge blog. download free source codes for python and java and other free stuff.

Video Tutorial for Configuration of Trunk Link and VLANS



#CCNA #CIsco #Networking #Tutorial #Video #Picture #Diagram #trunk #link #Router #switch #connection #3550 #Speed #Security #training #HCNA #HCIA #CCNP #HCNP

Trunk Links & VLAN Interfaces










#VLAN #Catalyst #Switch #Cisco #Network #CCNA #Networking #Interface #Trunk #Link #Interconnect #Backbone #Span #Switches #Image #Diagram

Access Links Ports



#VLAN #CISCO #Training #Switch #Port Frame #Packet Information ACCESS #Configured Diagram #nternal Backbone Image

knowledge streams blog spot dot com free knowledge blog. download free source codes for python and java and other free stuff.

Featured Post

Day 41 — BGP Confederations: Sub-AS Design, External View and Migration

1. Opening Confederations are another way to scale BGP inside a large administrative domain. They divide the domain into member autonomous systems while presenting a single confederation identifier to external peers. They are powerful, but their operational model is more complex than simply 'using private ASNs inside.' The engineering goal is not to memorize another BGP command. It is to understand what information each speaker is allowed to propagate, what path information can be hidden, and what failure domain is created by the chosen control-plane architecture . 2. Concept and standards behavior RFC 5065 defines AS_CONFED_SEQUENCE and AS_CONFED_SET and how member-AS relationships are represented. Confederation external sessions have eBGP-like properties inside the confederation, while the confederation is presented externally as one AS. Modern guidance must also account for the fact that RFC 9774 prohibits new origination of AS_SET/AS_CONFED_SET in ordinary aggregation c...