Thursday, 1 September 2016

Java Program (Age Comparison)

THREE AGE COMPARISON IN SWING PACKAGE


import javax.swing.JOptionPane;
    class Three_Age{
        public static void main(String[]args) throws Exception{
            String text = JOptionPane.showInputDialog("Enter First Age");
            int Age1 = Integer.parseInt(text);

            String text2 = JOptionPane.showInputDialog("Enter First Age");
            int Age2 = Integer.parseInt(text2);

            String text3 = JOptionPane.showInputDialog("Enter First Age");
            int Age3 = Integer.parseInt(text3);
    
        if( Age1 > Age2 && Age1 > Age3 )
            JOptionPane.showMessageDialog( null, Age1 + " is Greater" );
        if( Age2 > Age1 && Age2 > Age3 )
            JOptionPane.showMessageDialog( null, Age2 + " is Greater" );
        if( Age3 > Age1 && Age3 > Age2 )
            JOptionPane.showMessageDialog(null, Age3 + " is Greater" );
        if ( Age1 < Age2 && Age1 < Age3 )
            JOptionPane.showMessageDialog( null, Age1 + " is Smaller" );
        if( Age2 < Age1 && Age2 < Age3 )
            JOptionPane.showMessageDialog( null, Age2 + " is Smaller" );
        if( Age3 < Age1 && Age3 < Age2 )
            JOptionPane.showMessageDialog(null, Age3 + " is Smaller" );
        }
    }

Java Program (Complete Marksheet Using Swing)

COMPLETE MARKSHEET USING SWING PACKAGE


import javax.swing.JOptionPane;
    class swingMarksheet{
        public static void main(String[]args) throws Exception{
            String a = JOptionPane.showInputDialog("Enter Java Marks");
            int java = Integer.parseInt(a);
            String b = JOptionPane.showInputDialog("Enter PHP Marks");
            int php = Integer.parseInt(b);
            String c = JOptionPane.showInputDialog("Enter VB Marks");
            int vb = Integer.parseInt(c);
            String d = JOptionPane.showInputDialog("Enter C++ Marks");
            int cpp = Integer.parseInt(d);
            String e = JOptionPane.showInputDialog("Enter Ruby Marks");
            int ruby = Integer.parseInt(e);
           
            int total = 500;
            int obtained = java + php + cpp + vb + ruby;
            int percentage = obtained * 100 / total;
           
            if(java >39 && php >39 && vb >39 && cpp >39 && ruby >39 && (percentage <100 && percentage >=80))
               
JOptionPane.showMessageDialog(null, "Total Marks Are :" + total +
                 "\n Obtained Marks Are : " + obtained +
                 "\n Percentage is : " + percentage +"%" +
                 "\n You Are Pass" + "\n You Got A+ Grade");

            if(java >39 && php >39 && vb >39 && cpp >39 && ruby >39 && (percentage <80 && percentage >=70))
               
JOptionPane.showMessageDialog(null, "Total Marks Are :" + total +
                 "\n Obtained Marks Are : " + obtained +
                 "\n Percentage is : " + percentage +"%" +
                 "\n You Are Pass" + "\n You Got A Grade");

           
           if(java >39 && php >39 && vb >39 && cpp >39 && ruby >39 && (percentage <70 && percentage >=60))
               
JOptionPane.showMessageDialog(null, "Total Marks Are :" + total +
                 "\n Obtained Marks Are : " + obtained +
                 "\n Percentage is : " + percentage +"%" +
                 "\n You Are Pass" + "\n You Got B Grade");

           
           if(java >39 && php >39 && vb >39 && cpp >39 && ruby >39 && (percentage <60 && percentage >=50))
               
JOptionPane.showMessageDialog(null, "Total Marks Are :" + total +
                 "\n Obtained Marks Are : " + obtained +
                 "\n Percentage is : " + percentage +"%" +
                 "\n You Are Pass" + "\n You Got C Grade");

           
           if(java >39 && php >39 && vb >39 && cpp >39 && ruby >39 && (percentage <50 && percentage >=40))
               
JOptionPane.showMessageDialog(null, "Total Marks Are :" + total +
                 "\n Obtained Marks Are : " + obtained +
                 "\n Percentage is : " + percentage +"%" +
                 "\n You Are Pass" + "\n You Got D Grade");


            if(java <40 || php <40 || vb <40 || cpp <40 || ruby <40 || percentage < 40)
JOptionPane.showMessageDialog(null, "Total Marks Are :" + total +
                 "\n Obtained Marks Are : " + obtained +
                 "\n Percentage is : " + percentage +"%" +
                 "\n You Are Fail");
                                                 
        }
    }

Java Program (Find Out Greater and Smaller Age)

FIND OUT SMALLER AND LARGER AGE FROM TAKEN INPUT (SWING PACKAGE)


import javax.swing.JOptionPane;
    class FiveAge{
        public static void main(String[]args) throws Exception{
            String text = JOptionPane.showInputDialog("Enter First Age");
            int Age1 = Integer.parseInt(text);

            String text2 = JOptionPane.showInputDialog("Enter Second Age");
            int Age2 = Integer.parseInt(text2);

            String text3 = JOptionPane.showInputDialog("Enter Third Age");
            int Age3 = Integer.parseInt(text3);
   
            String text4 = JOptionPane.showInputDialog("Enter Fourth Age");
            int Age4 = Integer.parseInt(text4);
   
            String text5 = JOptionPane.showInputDialog("Enter Fifth Age");
            int Age5 = Integer.parseInt(text5);
   
            if( Age1 > Age2 && Age1 > Age3 && Age1 > Age4 && Age1 > Age5 )
            JOptionPane.showMessageDialog( null, Age1 + " is Greater" );
       
            if( Age2 > Age1 && Age2 > Age3 && Age2 > Age4 && Age2 > Age5 )
            JOptionPane.showMessageDialog( null, Age2 + " is Greater" );
       
            if( Age3 > Age1 && Age3 > Age2 && Age3 > Age4 && Age3 > Age5 )
            JOptionPane.showMessageDialog(null, Age3 + " is Greater" );
       
            if ( Age4 > Age1 && Age4 > Age2 && Age4 > Age3 && Age4 > Age5 )
            JOptionPane.showMessageDialog( null, Age4 + " is Greater" );
       
            if( Age5 > Age1 && Age5 > Age2 && Age5 > Age3 && Age5 > Age4 )
            JOptionPane.showMessageDialog( null, Age5 + " is Greater" );
   
            if( Age1 < Age2 && Age1 < Age3 && Age1 < Age4 && Age1 < Age5 )
            JOptionPane.showMessageDialog(null, Age1 + " is Smaller" );
       
            if( Age2 < Age1 && Age2 < Age3 && Age2 < Age4 && Age2 < Age5 )
            JOptionPane.showMessageDialog(null, Age2 + " is Smaller" );
       
            if( Age3 < Age1 && Age3 < Age2 && Age3 < Age4 && Age3 < Age5 )
            JOptionPane.showMessageDialog( null, Age3 + " is Smaller" );
       
            if( Age4 < Age1 && Age4 < Age2 && Age4 < Age3 && Age4 < Age5 )
            JOptionPane.showMessageDialog( null, Age4 + " is Smaller" );
       
            if( Age5 < Age1 && Age5 < Age2 && Age5 < Age3 && Age5 < Age4 )
            JOptionPane.showMessageDialog(null, Age5 + " is Smaller" );      
        }
    }

Saturday, 27 August 2016

Java Program

GUI (Swing) Based Even/Odd Number Recognition Java Program


import javax.swing.JOptionPane;
    class SwingEvenOdd{
        public static void main(String[]args) throws Exception{
            String season = JOptionPane.showInputDialog("Enter Number");
            int asd = Integer.parseInt(season);
        

  if(asd % 2 == 1)
                JOptionPane.showMessageDialog(null, "Number " + asd + " is odd");
  if(asd % 2 == 0)
                JOptionPane.showMessageDialog(null, "Number " + asd + " is even");                      
            
        }
    }

Java Program

GUI (Swing) Based Season Identifier Java Program


import javax.swing.JOptionPane;
    class SeasonIdentifier{
        public static void main(String[]args) throws Exception{
               String season = JOptionPane.showInputDialog("Enter season number");
            int asd = Integer.parseInt(season);
            

            if(asd == 1 || asd == 11 || asd == 12)
                JOptionPane.showMessageDialog(null, "The Number: " + asd + "\n Wellcome to WINTER season");
            if(asd == 2 || asd == 3 || asd == 4)
                JOptionPane.showMessageDialog(null, "The Number: " + asd + "\n Wellcome to SPRING season");
            if(asd == 5 || asd == 6 || asd == 7)
                JOptionPane.showMessageDialog(null, "The Number: " + asd + "\n Wellcome to SUMMER season");
            if(asd == 8 || asd == 9 || asd == 10)
                JOptionPane.showMessageDialog(null, "The Number: " + asd + "\n Wellcome to AUTUMN season");
            if(asd < 1 || asd > 12)
                JOptionPane.showMessageDialog(null, "Invalid Month Number");

        }
    }

Java Program

GUI Based Payroll System Java Program


import javax.swing.JOptionPane;
    class salary{
        public static void main(String[]args) throws Exception{
            
            String pay = JOptionPane.showInputDialog("Enter Basic Pay");
            int basicpay = Integer.parseInt(pay);
            
                    JOptionPane.showMessageDialog(null, "Basic Salary: " +  pay);
            
            int houserent = basicpay * 25 / 100;
            int conveyance = basicpay * 15 / 100;
            int medical = basicpay * 35 / 100;
            int governance = basicpay * 5 / 100;
            int total_salary = basicpay + houserent + conveyance + medical + governance;
            
            int tax = basicpay * 14 / 100;
            int zakat = basicpay * 25 / 100;
            int gross_pay = tax + zakat;
            
            int net_salary = total_salary - gross_pay;
                        
        JOptionPane.showMessageDialog(null, "ALLOUNCES " + 
                    "\n House rent 35% : " + houserent +
                    "\n Conveyance is 15% : " + conveyance +
                    "\n Medical Allounce 35% : " + medical + 
                    "\n Governance Allounce 5% : " + governance +
                    "\n Total Salary is : " + total_salary );
        
        JOptionPane.showMessageDialog(null, "DEDUCTIONS " + 
                    "\n Government Tax : " + tax + "\n Annual Zakat :"                                       + zakat + "\n Total Deductions " + gross_pay);

        JOptionPane.showMessageDialog(null, "Net Salary " + net_salary );
        }
    }

/*given * 100 divide total == percentage
    
    */

Java Program

GUI Based Currency Converter Java Program


import javax.swing.JOptionPane;
    class converter{
        public static void main(String[]args) throws Exception{
            String amount = JOptionPane.showInputDialog("Enter rupees");
            int asd = Integer.parseInt(amount);
        
        float us_dollor = asd / 104f;
        float aus_dollor = asd / 78f;
        float riyal = asd / 28f;
        float deenar = asd / 358f;
            JOptionPane.showMessageDialog(null, "Pakistani Rupees" + asd + 
                        "\n In US Dollors: " + us_dollor + 
                        "\n Australian Dollors : " + aus_dollor +
                        "\n Saudi Riyal : " + riyal +
                        "\n Deenar : " + deenar );
        }
    }