Kasus 3.5

Pertanyaan :

Buatlah algoritma, flowchart, dan program untuk mengkonversi hari ke-1 adalah hari Senin sampai dengan hari ke-7 adalah Minggu.
Misalkan dimasukkan nilai 3, outputnya adalah hari Rabu.


#include <iostream>
#include <string>

using namespace std;
int main(){
   int hari;
   cout<<"Masukkan nilai untuk melihat hari : ";
   cin >> hari;
   if (hari==1)
   {
      cout << "Hari Senin" << endl;   }
   else
   {
      if (hari==2)
      {
         cout << "Hari Selasa" << endl;      }
      else
      {
         if (hari==3)
         {
            cout << "Hari Rabu" << endl;         }
         else
         {
            if (hari==4)
            {
               cout << "Hari Kamis" << endl;            }
            else
            {
               if (hari==5)
               {
                  cout << "Hari Jumat" << endl;               }
               else
               {
                  if (hari==6)
                  {
                     cout << "Hari Sabtu" << endl;                  }
                  else
                  {
                     cout << "Hari Minggu" << endl;                  }
               }
            }
         }
      }
   }

   return 0;
}


Raptor :

Share on Google Plus

About Luthfi

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment