Advertisement
pablopalacios

função y or n burra e burocrática

Sep 11th, 2013
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.   while(true) {
  7.     char yn;
  8.     cout << "Iniciar programa? (y or n)" << endl;
  9.     cin >> yn;
  10.     if(yn=='y'){
  11.       double metric_ton, ounces;
  12.       cout << "Type the weight in ounces: ";
  13.       cin >> ounces;
  14.  
  15.       metric_ton = ounces / 35273.92;
  16.       cout << endl;
  17.       cout << "Weight in metric tons: " << metric_ton << endl << endl;
  18.       cout << "- - - - - - - - - - - - - - - - - - - - - - - - - - -";
  19.       cout << endl << endl;
  20.     }
  21.     else {
  22.       if (yn=='n'){
  23.     break;
  24.       }
  25.       else {
  26.     cout << "Opção não válida, tente novamente" << endl;
  27.       }
  28.     }
  29.   }
  30.   return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement