Time Difference

Time Difference

Just open your c++ compiler Paste this code.


#include<iostream>
using namespace std;

class time
{
private :

int hour,minutes,seconds;
 
public :

time() : hour(0),minutes(0),seconds(0)
{
}

time(int hr,int min,int sec) : hour(hr), minutes(min), seconds(sec)
{
}

void display()
{
cout<<hour<<":";
cout<<minutes;
cout<<":";
cout<<seconds;
cout<<"\n";


}
void add(int x,int y,int z,int n,int m,int o)
{
int p;
int q;
int r;
p=x+n;
q=y+m;
r=z+o;
cout<<"the time after add is ";
cout<<p<<":"<<q<<":"<<r;

}

};

int main()
{
int a,b,c,d,e,f;
time time3;

cout<<"enter the hours =";
cin>>a;
cout<<"enter the minutes =";
cin>>b;
cout<<"enter the seconds =";
cin>>c;
cout<<"enter the hours =";
cin>>d;
cout<<"enter the minutes =";
cin>>e;
cout<<"enter the seconds =";
cin>>f;
for(int h=0;h<=2;h--)
{


if (b>=60)
{
b-=60;
a++;
}
else if (c>=60)
{
c-=60;
b++;
}
else if (e>=60)
{
e-=60;
d++;
}
else if (f>=60)
{
f-=60;
e++;
}
    else if (b<60 && c<60 && e<60 && f<60)
    {
    break;
    }

}
time time1(a,b,c);
time time2(d,e,f);

if(a>24)
{
cout<<"the time 1 exceeds the 24 hours format\n";
cout<<"but the time given is";
time1.display();
cout<<"\n";
   
}

if(d>24)
    {
    cout<<"the time 2 exceeds the 24 hours format\n";
       cout<<"but the time given is";
   time2.display();
   cout<<"\n";
   
}

if(a<24)
{
cout<<"the time 1 is";
time1.display();
}

    if(d<24)
    {
   
    cout<<"the time 2 is";
time2.display();
   
}
 
    time3.add(a,b,c,d,e,f);
   
}

Comparison 2 (Feet And Inches)

Comparison  2 (Feet And Inches)

Just open your c++ compiler Paste this code.


#include<iostream>
using namespace std;

class Distance
{
int feet;
float inches;
public:
Distance():feet(0),inches(0)
{
}
    Distance(int ft,float in):feet(ft),inches(in)
    {
    }
    void sub(int w,float x,int y,float z)
    {
    int f;
    float i;
    f = w-y;
    i = x-z;
        cout<<"distance 1 - distance 2 is = ";
    cout<<f<<"'"<<i<<"''";
    }
   


};

int main()
{
Distance dist3;
int a,c;
float d,e;
cout<<"enter the feet =";
cin>>a;
cout<<"enter the inches =";
cin>>e;
cout<<"distance 2\n";
cout<<"enter the feet =";
cin>>c;
cout<<"enter the  inches =";
cin>>d;
if(e>=12)
{
a++;
e-=12;
}
Distance dist1(a,e);
if(d>=12)
{
c++;
d-=12;
}
Distance dist2(c,d);
   if(a>c)
   {
 
   dist3.sub(a,e,c,d);
   }
   else
   {
    cout<<"2nd distance is greater";
   }
}

Simple Parameter Constructor

Simple Parameter Constructor 

Just open your c++ compiler Paste this code.


#include<iostream>
using namespace std;
class emp
{
private :
int em,co;
public :
emp() :em(0) , co(0)
{

}
emp(int empo ,int comp) : em(empo) , co(comp)
{

}
int setemployee(int bc,int ac)
{
cout<<"Employee No IS : "<<bc<<endl;
cout<<"Employee salary is : "<<ac<<endl;
}
};
int main()
{
emp p;
int a,b;
cout<<"Enter Employee NO : ";
cin>>a;
cout<<"Enter Employee Salery : ";
cin>>b;
emp as(a,b);
p.setemployee(a,b);
emp as1(a,b);
p.setemployee(a,b);


}

Adding 2 value Using Java

Adding 2 value Using Java

Just open your Java compiler Paste this code.

package javaapplication13;

/**
 *
 * @author Xaiver
 */

public class JavaApplication13 {

    /**
     * @param args the command line arguments
     */
   
    import java.util.Scanner;
    public static void main(String[] args) {
         Scanner input = new Scanner(System.in);
    }
        // TODO code application logic here
         public static void hstal(){
        int a;
        System.out.println("enter the first number");
        int b;
        System.out.println("enter the second number");
        int v=a+b;
               
         System.out.println(v);
        hstal();
    }
   

}

Enter Time Hour And second and print

Enter Time Hour And second and print

Just open your c++ compiler Paste this code.


#include<iostream>
using namespace std;
class time
{
private :
int sec,min,hour;
public:

void getdate()
{
cout<<"Enter Seceond";
cin>>sec;
cout<<"Enter Minute";
cin>>min;
cout<<"Enter Hour";
cin>>hour;
}
void showdate()
{
cout<<sec<<":"<<min<<":"<<hour<<".";
}

};
int main()
{

time t;
t.getdate();
t.showdate();
}

Find Time Hours And Second

Find Time Hours And Second 

Just open your c++ compiler Paste this code.

#include<iostream>
using namespace std;

class time
{
private :

int hour,minutes,seconds;
 
public :

time() : hour(0),minutes(0),seconds(0)
{
}

time(int hr,int min,int sec) : hour(hr), minutes(min), seconds(sec)
{
}

void display()
{
cout<<hour<<":";
cout<<minutes;
cout<<":";
cout<<seconds;
cout<<"\n";


}
void add(int x,int y,int z,int n,int m,int o)
{
int p;
int q;
int r;
p=x+n;
q=y+m;
r=z+o;
cout<<"the time after add is ";
cout<<p<<":"<<q<<":"<<r;

}

};

int main()
{
int a,b,c,d,e,f;
time time3;

cout<<"enter the hours =";
cin>>a;
cout<<"enter the minutes =";
cin>>b;
cout<<"enter the seconds =";
cin>>c;
cout<<"enter the hours =";
cin>>d;
cout<<"enter the minutes =";
cin>>e;
cout<<"enter the seconds =";
cin>>f;
for(int h=0;h<=2;h--)
{


if (b>=60)
{
b-=60;
a++;
}
else if (c>=60)
{
c-=60;
b++;
}
else if (e>=60)
{
e-=60;
d++;
}
else if (f>=60)
{
f-=60;
e++;
}
    else if (b<60 && c<60 && e<60 && f<60)
    {
    break;
    }

}
time time1(a,b,c);
time time2(d,e,f);

if(a>24)
{
cout<<"the time 1 exceeds the 24 hours format\n";
cout<<"but the time given is";
time1.display();
cout<<"\n";
   
}

if(d>24)
    {
    cout<<"the time 2 exceeds the 24 hours format\n";
       cout<<"but the time given is";
   time2.display();
   cout<<"\n";
   
}

if(a<24)
{
cout<<"the time 1 is";
time1.display();
}

    if(d<24)
    {
   
    cout<<"the time 2 is";
time2.display();
   
}
 
    time3.add(a,b,c,d,e,f);
   
}

First Parameter Constructor

First Parameter Constructor

Just open your c++ compiler Paste this code.

#include<iostream>
using namespace std;
class perameter
{
    public:  

 int ali=1245;
perameter(int year)
{
cout<<"hello i am perameter const"<<year;
}  

};
int main()
{
perameter ali();
cout<<"Hello i am awe"<<ali<<endl;
perameter m(19129);


}