Menentukan Tahun Kabisat dengan C++

#include <iostream.h>
#include <string.h>
#include <conio.h>

class Kabisat
{
  private:
    int l;
    char tahun[4];

  public:
    Kabisat();
    void hitungKabisat();
    friend istream &operator >> (istream &in, Kabisat &);
    friend ostream &operator << (ostream &out, Kabisat &);
};

int main()
{
  Kabisat x;

  cin >> x;
  cout << x;

  system ("pause");
  return EXIT_SUCCESS;

}


Kabisat::Kabisat(){
 
  cout << "MENENTUKAN TAHUN KABISAT" << endl;}

void Kabisat::hitungKabisat()
{
    if ( l % 4 != 0)
      strcpy(tahun,"Bukan Tahun kabisat");
    else
        strcpy(tahun,"tahun kabisat");

}

istream &operator >> (istream &in, Kabisat &masukan)
{
  cout<<"Lukman Reza Memasukan tahun : " ;
  in>>masukan.l;

  return in;
}

ostream &operator << (ostream &out, Kabisat &tampil)
{
  tampil.hitungKabisat();
  out << tampil.l << "  "<< tampil.tahun << endl;
  return out;
}

Posting Komentar

0 Komentar