Guest User

Untitled

a guest
Jan 24th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.20 KB | None | 0 0
  1. #include "stdafx.h"
  2.  
  3. using namespace System;
  4.  
  5. int main(array<System::String ^> ^args)
  6. {
  7.     int numSeconds = 0;
  8.     Console::Write("Sekunder du vil konvertere: ");
  9.     String^ str = Console::ReadLine();
  10.     numSeconds = System::Convert::ToInt32(str);
  11.     int convert = (numSeconds % 3600);
  12.     int timer = ((numSeconds - convert)/3600);
  13.     int sekunder = (convert % 60);
  14.     int minutter = ((convert - sekunder) / 60);
  15.     Console::WriteLine();
  16.     bool loop = true;
  17.  
  18.     while(loop){
  19.         if(numSeconds > 0){
  20.             String^ hours = "";
  21.             if(timer == 1)
  22.                 hours = "time, ";
  23.             else
  24.                 hours = "timer, ";
  25.             if(timer > 0)
  26.                 Console::Write(timer + hours);
  27.  
  28.             String^ minutes = "";
  29.             if(minutter == 1)
  30.                 minutes = " minutt, ";
  31.             else
  32.                 minutes = " minutter, ";
  33.             if(minutter > 0)
  34.                 Console::Write(minutter + minutes);
  35.    
  36.             String^ seconds = "";
  37.             if(sekunder == 1)
  38.                 seconds = " sekund.";
  39.             else
  40.                 seconds = " sekunder.";
  41.             if(sekunder > 0)
  42.                 Console::Write(sekunder + seconds);
  43.  
  44.             Console::ReadLine();
  45.             loop = false;
  46.         }else
  47.             Console::WriteLine(L"Du må skrive inn et tall større enn 0");
  48.     } //Litt feil med Exception-handling, hvis det i det hele tatt eksisterer i C++ :P
  49.     return 0;
  50. }
Add Comment
Please, Sign In to add comment