avv210

Formulir Mahasiswa Sederhana

Sep 17th, 2021
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip> // std::put_time()
  3. #include <chrono>  // std::chrono::system_clock
  4. #include <ctime>   // std::time_t, struct std::tm, std::localtime
  5. using std::string;
  6. using std::cout;
  7. using std::cin;
  8. using std::chrono::system_clock;
  9.  
  10. void makeLine( int len )
  11. {
  12.     for ( int i = 0; i < len; i++ )
  13.         cout << "=";
  14.     cout << "\n";
  15. }
  16.  
  17. int main()
  18. {
  19.     string fullName;
  20.     string dateOfBirth;
  21.     string address;
  22.     string gender;
  23.     string email;
  24.     string phoneNumber;    
  25.     string NIM;
  26.     string buffer;
  27.     std::time_t time = system_clock::to_time_t(system_clock::now());
  28.     struct std::tm* ptm = std::localtime(&time);
  29.  
  30.     makeLine(45);
  31.     cout << "\tFormulir Data Diri Mahasiswa\t\n";
  32.     cout << "\tTanggal: " << std::put_time(ptm, "%c") << "\n";
  33.     makeLine(45);
  34.     cout << "Input data anda dibawah ini\n\n";
  35.     cout << "Email\t\t: "; getline(cin, email);
  36.     cout << "Nama\t\t: "; getline(cin, fullName);
  37.     cout << "NIM\t\t: "; getline(cin, NIM);
  38.     cout << "Jenis Kelamin\t: "; getline(cin, gender);
  39.     cout << "Tgl. Lahir\t: "; getline(cin, dateOfBirth);
  40.     cout << "Alamat\t\t: "; getline(cin, address);
  41.     cout << "No. Tlp\t\t: "; getline(cin, phoneNumber);
  42.     makeLine(45);
  43.     cout <<  "\t    Hasil Input Formulir\n\n";
  44.     cout << "Email\t\t: " << email << "\n";
  45.     cout << "Nama\t\t: " << fullName << "\n";
  46.     cout << "NIM\t\t: " << NIM << "\n";
  47.     cout << "Jenis Kelamin\t: " << gender << "\n";
  48.     cout << "Tgl. Lahir\t: " << dateOfBirth << "\n";
  49.     cout << "Alamat\t\t: " << address << "\n";
  50.     cout << "No. Tlp\t\t: " << phoneNumber << "\n\n";
  51.  
  52.     cout << "Program berakhir.....\nTerima kasih telah menggunakan program ini :D\n\n";    
  53.     system("PAUSE");
  54.  
  55.     return 0;
  56. }
  57.  
  58. // References:
  59. // https://www.cplusplus.com/reference/iomanip/put_time/
Advertisement
Add Comment
Please, Sign In to add comment