Thursday, 11 May 2017

Java Program For Find The Salary Of An Employee With Employee Grade

Problem :- Java Program For Find The Salary Of An Employee With Employee Grade (Performance).

Note :- Please See This is A Requested Problem From Pakistan .See You Can Also Requested Any Problem Regarding Programming .So Don't Forgot To Share Thanks Learning Point (Chowk azam, Pakistan) Writing For Us 

"write a code in java that input salary and grade of an employee and apply below conditions:
i) in case of grade 15 or above than bonus is 15%
ii) in case of grade 16 or above than bonus is 20%
iii) in case of grade 18 or above than bonus is 25%
iv) after calculating total salary deduct 13% GST in case that salary is 15000 or above. deduct 15% GST and in case that salary is 22000 or above.
v) Add 6% bonus at the end 
Calculate net salary according to above condition and display it.
"


Java Program For Find The Salary Of An Employee With Employee Grade


Logic :- So according to first three condition in problem i use if else Statement For grade of employee See Below .

if(grade==15)
{
bonus=(basic_salary*15)/100;
}
else if(grade==16 || grade==17 )
{
bonus=(basic_salary*20)/100;
}
else if(grade>=18)
{
bonus=(basic_salary*25)/100;
}

After That We Get a Basic Salary + Bonus . Now According to GST ( Goods and Service Tax ) Conditions Calculate a remaining Salary After All Calculation 6% Bonus  .

if(basic_salary>=15000 && basic_salary<22000)
{
gst=(basic_salary*13)/100;

basic_salary-=gst;

bonus1=(basic_salary*6)/100;

basic_salary+=bonus1;

}
else if(basic_salary>=22000)
{
gst=(basic_salary*15)/100;

basic_salary-=gst;

bonus1=(basic_salary*6)/100;

basic_salary+=bonus1;

}
        else
{
bonus1=(basic_salary*6)/100;

basic_salary+=bonus1;
}

At the End Print The Salary .

Example :- Lets Assume Employee Salary is 20,000 And Grade is 15 Then Calculate a Employee Salary  .

20,000 Salary and 15 Grade Bonus is 15% then Bonus =3000 .

Now Total Salary is 20,000+3000=23,000

Now Salary is Greater than 22,000 Then 15% GST ,So GST=3450 .

Now Total Salary is 23,000-3450=19550 .

At the End 6% Bonus Then Bonus = 1173

So Gross Salary Of Employee is =19500+1173=20723.

Gross Salary = 20723 .

Try This Java Program For Find The Gross Salary Of An Employee

Solution :-

import java.util.Scanner;
class employeesalary
{
 public static void main(String args[]) 
 {
float basic_salary,bonus1=0,bonus=0,gst;
int grade;

Scanner scan=new Scanner(System.in);

System.out.println("Enter Basic Salary Of Employee : ");
basic_salary=scan.nextFloat();

System.out.println("\nEnter The Grade Of Employee : ");    
grade=scan.nextInt();

if(grade==15)
{
bonus=(basic_salary*15)/100;
}
else if(grade==16 || grade==17 )
{
bonus=(basic_salary*20)/100;
}
else if(grade>=18)
{
bonus=(basic_salary*25)/100;
}

basic_salary+=bonus;

if(basic_salary>=15000 && basic_salary<22000)
{
gst=(basic_salary*13)/100;

basic_salary-=gst;

bonus1=(basic_salary*6)/100;

basic_salary+=bonus1;

}
else if(basic_salary>=22000)
{
gst=(basic_salary*15)/100;

basic_salary-=gst;

bonus1=(basic_salary*6)/100;

basic_salary+=bonus1;
}
else
{
bonus1=(basic_salary*6)/100;

basic_salary+=bonus1;
}

    System.out.println("\nGross Salary Of Employee : "+basic_salary);

  }


Output :-


Java Program For Find The Salary Of An Employee With Employee Grade

Thursday, 6 April 2017

Geeksforgeeks Solution For " Two Repeated Elements "

GeeksforGeeks Solution For Hard Domain .Below You Can Find The Solution Of  School Basic ,Easy ,Medium . Or Hackerrank Solution You Can Also Direct Submit Your Solution to Geeksforgeeks Same Problem .You Need to login then you can submit you answers 

Problem :- Two Repeated Elements

Submit Your Solution :- Click Here 

Solution :- 

#include<iostream>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--){
   int n;
   cin>>n;
   int a[n+2],b[n+2]={};

   for(int i=0;i<n+2;i++){
       cin>>a[i];
       b[a[i]]=b[a[i]]+1;
       if(b[a[i]]==2)
           cout<<a[i]<<" ";
   }
   cout<<endl;
}
return 0;
}

Output:-



Geeksforgeeks Solution For " Two Repeated Elements "

Geeksforgeeks Solution For " Sum of Middle Elements of two sorted arrays "

GeeksforGeeks Solution For Hard Domain .Below You Can Find The Solution Of  School Basic ,Easy ,Medium . Or Hackerrank Solution You Can Also Direct Submit Your Solution to Geeksforgeeks Same Problem .You Need to login then you can submit you answers 

Problem :- Sum of Middle Elements of two sorted arrays

Submit Your Solution :- Click Here 

Solution :- 

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
int t,n,val;
cin>>t;
while(t--){

cin>>n;
int a[n],b[n];
vector<int>c(2*n);
for(int i=0;i<n;i++){
cin>>a[i];
}

for(int i=0;i<n;i++){
cin>>b[i];
}
merge(a,a+n,b,b+n,c.begin());
int s=c.size();
cout<<(c[(s/2)-1]+c[s/2])<<endl;

}
}

Output:-



Geeksforgeeks Solution For " Sum of Middle Elements of two sorted arrays "

Geeksforgeeks Solution For " Stock buy and sell "

GeeksforGeeks Solution For Hard Domain .Below You Can Find The Solution Of  School Basic ,Easy ,Medium . Or Hackerrank Solution You Can Also Direct Submit Your Solution to Geeksforgeeks Same Problem .You Need to login then you can submit you answers 

Problem :- Stock buy and sell

Submit Your Solution :- Click Here 

Solution :- 

#include<bits/stdc++.h>
using namespace std;
int main()
 {
int t;
    cin>>t;
    while(t--)
    {
        int n;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++)
       cin>>a[i];
   int buy=0,sell=0;
   bool key=false;
   for(int i=1;i<n;i++)
   {
       if(a[i]>a[i-1])
           sell++;
       else
       {
           if(buy!=sell)
           {
               cout<<"("<<buy<<" "<<sell<<") ";
               key=true;
           }
           buy=sell=i;
       }
   }
   if(buy!=sell)
   {
       cout<<"("<<buy<<" "<<sell<<") ";
        key=true;
   }
   if(!key)
        cout<<"No Profit";
   cout<<endl;       
    }
return 0;
}

Output:-



Geeksforgeeks Solution For " Stock buy and sell "

Geeksforgeeks Solution For " Reverse Coding "

GeeksforGeeks Solution For Hard Domain .Below You Can Find The Solution Of  School Basic ,Easy ,Medium . Or Hackerrank Solution You Can Also Direct Submit Your Solution to Geeksforgeeks Same Problem .You Need to login then you can submit you answers 

Problem :- Reverse Coding

Submit Your Solution :- Click Here 

Solution :- 

#include <iostream>
using namespace std;

int main() {
int t;
cin>>t;
while(t--){
   int n,m;
   cin>>n>>m;
   int c=(n*(n+1))/2;
   if(c==m)
       cout<<1<<endl;
        else
            cout<<0<<endl;
}
return 0;
}

Output:-



Geeksforgeeks Solution For " Reverse Coding "

Geeksforgeeks Solution For " Move all negative elements to end "

GeeksforGeeks Solution For Hard Domain .Below You Can Find The Solution Of  School Basic ,Easy ,Medium . Or Hackerrank Solution You Can Also Direct Submit Your Solution to Geeksforgeeks Same Problem .You Need to login then you can submit you answers 

Problem :- Move all negative elements to end

Submit Your Solution :- Click Here 

Solution :- 

#include <iostream>
#include <vector>
using namespace std;

int main() {
int t;
    cin>>t;
    while(t--){
        int no,p=0,n=0;
        cin>>no;
        vector<int> po,ng;
        int a[no];
        for(int i=0;i<no;i++){
            cin>>a[i];
            if(a[i]>=0){
                p++;
                po.push_back(a[i]);
            }    
            else{
                n++;
                ng.push_back(a[i]);
            }    
        }
        for(int i=0;i<p;i++)
            a[i]=po[i];
        for(int i=0;i<n;i++)    
            a[p+i]=ng[i];
        for(int i=0;i<no;i++)    
            cout<<a[i]<<" ";
        cout<<endl;    
    }
return 0;
}

Output:-



Geeksforgeeks Solution For " Move all negative elements to end "

Geeksforgeeks Solution For " Maximum repeating number "

GeeksforGeeks Solution For Hard Domain .Below You Can Find The Solution Of  School Basic ,Easy ,Medium . Or Hackerrank Solution You Can Also Direct Submit Your Solution to Geeksforgeeks Same Problem .You Need to login then you can submit you answers 

Problem :- Maximum repeating number

Submit Your Solution :- Click Here 

Solution :- 

#include <bits/stdc++.h>
using namespace std;

int main() {
int t;
cin>>t;
while(t--){
   int n, k;
   cin>>n>>k;
   int a[n], b[n]={};
   for(int i=0; i<n; i++){
       cin>>a[i];
       b[a[i]]=b[a[i]]+1;
   }
   int index=0,max_v=b[0];
           
            for(int i=0;i<k;i++)
                if(b[i]>max_v){
                    max_v=b[i];
                    index=i;
                }
            cout<<index<<endl;
}
return 0;
}

Output:-



Geeksforgeeks Solution For " Maximum repeating number "

Geeksforgeeks Solution For " Maximum no of 1's row "

GeeksforGeeks Solution For Hard Domain .Below You Can Find The Solution Of  School Basic ,Easy ,Medium . Or Hackerrank Solution You Can Also Direct Submit Your Solution to Geeksforgeeks Same Problem .You Need to login then you can submit you answers 

Problem :- Maximum no of 1's row

Submit Your Solution :- Click Here 

Solution :- 

#include <iostream>
using namespace std;

int main() {
int t;
cin>>t;
while(t--){
   int r,c,i,j,row_n,prev_c=0,cur_c;
   cin>>r>>c;
   bool a[r][c];
   for(i=0; i<r; i++)
       for(j=0; j<c; j++)
           cin>>a[i][j];
   
   for(i=0; i<r; i++){
       cur_c=0;
       for(j=0; j<c; j++){
          if(a[i][j]==1)
           cur_c++;
       }   
       if(cur_c>prev_c){
            row_n=i;
       prev_c=cur_c;
       }
               
   }     
   cout<<row_n<<endl;
}
return 0;
}

Output:-



Geeksforgeeks Solution For " Maximum no of 1's row "

Geeksforgeeks Solution For " Key Pair "

GeeksforGeeks Solution For Hard Domain .Below You Can Find The Solution Of  School Basic ,Easy ,Medium . Or Hackerrank Solution You Can Also Direct Submit Your Solution to Geeksforgeeks Same Problem .You Need to login then you can submit you answers 

Problem :- Key Pair

Submit Your Solution :- Click Here 

Solution :- 

#include <iostream>
using namespace std;

int main() {
int t;
cin>>t;
while(t--){
   int n,x;
   cin>>n>>x;
   int a[n];
   for(int i=0; i<n; i++)
       cin>>a[i];
   int key=0;
   for(int i=0; i<n-1; i++)
       for(int j=i+1; j<n; j++){
           if((a[i]+a[j])==x){
               key=1;
               break;
           }
       }
       
   
   if(key)
       cout<<"Yes"<<endl;
   else
       cout<<"No"<<endl;
}
return 0;
}

Output:-



Geeksforgeeks Solution For " Key Pair "

Geeksforgeeks Solution For " Element that appears once where every element occurs twice "

GeeksforGeeks Solution For Hard Domain .Below You Can Find The Solution Of  School Basic ,Easy ,Medium . Or Hackerrank Solution You Can Also Direct Submit Your Solution to Geeksforgeeks Same Problem .You Need to login then you can submit you answers 

Problem :-  Element that appears once where every element occurs twice

Submit Your Solution :- Click Here 

Solution :- 

#include <iostream>
using namespace std;

int appearance(int a[],int n){
    int res=a[0];
    //int bit_mask;
    for(int i=1; i<n; i++){
        res=res^a[i];
    }
    return res;
}

int main() {
int t;
cin>>t;
while(t--){
   int n;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++)
       cin>>a[i];
   cout<<appearance(a,n)<<endl;
   
}
return 0;
}

Output:-



Geeksforgeeks Solution For " Element that appears once where every element occurs twice "
Add caption