Advertisement
LightProgrammer000

Cálculo [Tempo de Vida]

Nov 26th, 2018
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.07 KB | None | 0 0
  1. /// Bibliotecas
  2. #include <conio.h>
  3. #include <iostream>
  4. #include <stdlib.h>
  5. #include <locale.h>
  6. using namespace std;
  7.  
  8. /// Funções
  9. void Vida();
  10. char Menu (char cod);
  11.  
  12. /// Programa
  13. int main( int argc, char *argv[] )
  14. {
  15.     // Variável Estratégica
  16.     char cod = 'A';
  17.  
  18.     // Estrutura de Repetição
  19.     while ( cod != 'n' && cod != 'N' )
  20.     {
  21.         // Sistemas
  22.         setlocale(LC_ALL, "");
  23.         system("cls & color A");
  24.  
  25.         // Apresentação
  26.         cout << " ========================== " << endl;
  27.         system("echo  - Usuario: %username%");
  28.         system("echo  - Computador: %computername%");
  29.         system("echo  - Hora: %time:~0,-3%");
  30.         system("echo  - Data: %date:/=-%");
  31.         cout << " ========================== " << endl;
  32.  
  33.         Vida();
  34.  
  35.         // Menu Interativo
  36.         cod = Menu(cod);
  37.     }
  38.  
  39.     return(0);
  40. }
  41.  
  42. // Menu
  43. char Menu (char cod)
  44. {
  45.     // Entrada de Dados
  46.     cout << "\n - Deseja Retornar ?" << endl;
  47.     cout << " - [s] Sim \n - [n] Não" << endl;
  48.     cout << " - Opc: ";
  49.     cod = getche();
  50.     cout << "" << endl;
  51.  
  52.     return(cod);
  53. }
  54.  
  55. // Vida
  56. void Vida()
  57. {
  58.     // Variáveis
  59.     int ida;
  60.     int seg, mit, hor, dia, sem, mes;
  61.  
  62.     // Entrada de Dados
  63.     cout << "\n ============== " << endl;
  64.     cout << "      VIDA      " << endl;
  65.     cout << " ============== " << endl;
  66.  
  67.     cout << "\n - Digite a sua Idade: ";
  68.     cin >> ida;
  69.  
  70.     // Cálculos
  71.     seg = ida * 365 * 24 * 60 * 60;
  72.     mit = ida * 365 * 24 * 60;
  73.     hor = ida * 365 * 24;
  74.     dia = ida * 365;
  75.     sem = ida * 365 / 52;
  76.     mes = ida * 365 / 12;
  77.  
  78.     // Entrada de Dados
  79.     system("cls & color B");
  80.     cout << "\n =================== " << endl;
  81.     cout << "      RESULTADO      " << endl;
  82.     cout << " =================== " << endl;
  83.     cout << "\n - Segundos: " << seg << endl;
  84.     cout << "\n - Minutos: " << mit << endl;
  85.     cout << "\n - Horas: " << hor << endl;
  86.     cout << "\n - Dias: " << dia << endl;
  87.     cout << "\n - Semanas: " << sem << endl;
  88.     cout << "\n - Meses: " << mes << endl;
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement