Search the Whole World Here.,.,

Showing posts with label Knowledge Based Info.. Show all posts
Showing posts with label Knowledge Based Info.. Show all posts

Net Payable Amount (GUI) - JAVA Project

Code to add under jButton1


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

        //We will add the function.

        double price = Double.parseDouble(jTextField1.getText());
        double qty = Double.parseDouble(jTextField2.getText());             //double is used for values in points.
     
        double salAmt = price * qty;
        double disc = salAmt * 0.10;
        double netAmt = salAmt - disc;
     
        jTextField3.setText(" "+salAmt);
        jTextField4.setText(" "+disc);
        jTextField5.setText(" "+netAmt);        //Shortcut key used is SHIFT + DOWN ARROW.
    }




C Program : Factorial Program using Recursion


#include<stdio.h>
long factorial(int n) {  
  
  if (n == 0)  
    return 1;  
  else  
    return(n * factorial(n-1));  
    }  
   
void main(){  
 
     int number;  
     long fact;  

     printf("Enter a number: ");  
     scanf("%d", &number);   
   
     fact = factorial(number);  
     printf("Factorial of %d is %ld\n", number, fact);  
 
     return 0;  
}  





Output:
Enter a number: 6
Factorial of 5 is: 720

C Program : Factorial Program using loop





#include<stdio.h>
int main(){
    
           int i,fact=1,number;    
           printf("Enter a number: ");    
           scanf("%d",&number); 
   
           for(i=1;i<=number;i++){    
                fact=fact*i;    
                }    
  
          printf("Factorial of %d is: %d",number,fact);    

          return 0;  
         }   


Output:
Enter a number: 5
Factorial of 5 is: 120

C Program : Palindrome



Let's see the palindrome program in C. In this c program, we will get an input from the user and check whether number is palindrome or not.




#include  
int main(){    


           int n,r,sum=0,temp;    
           printf("enter the number=");    
           scanf("%d",&n);    
           temp=n;  
  
           while(n>0){    
                   
                  r=n%10;    
                  sum=(sum*10)+r;    
                  n=n/10;    
                 }    

          if(temp==sum)    
          printf("palindrome number ");    
 
          else    
          printf("not palindrome");   

          return 0;  
       }   



Output:
enter the number=151
palindrome  number
enter the number=5621
not palindrome  number

C Program : Prime Number


#include  
int main(){   

 
       int n,i,m=0,flag=0;    
       printf("Enter the number to check prime:");    
       scanf("%d",&n);    
       m=n/2;
    
       for(i=2;i<=m;i++){
    
               if(n%i==0){   
                    printf("Number is not prime");
                    flag=1;    
                    break;    
                     }    
            }   
 
     if(flag==0)    
     printf("Number is prime");     

     return 0;  
    }



Output:
Enter the number to check prime:56
Number is not prime
Enter the number to check prime:23
Number is prime

Ads by Google