Advertisement
Guest User

Vinyl C++ update

a guest
Jan 14th, 2013
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.78 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void Welcome()
  6. {
  7.     cout << "Welcome to Vinyl Scratch's MathFinder!\r\n";
  8.     cout << "It's my first C++ program, so I wanted to see if you guys liked it, and if I did well.\r\n\r\n\r\n";
  9. }
  10.  
  11.  
  12. int main()
  13. {
  14.  
  15.     unsigned long Width, Height, Base, Width2, Length2;
  16.  
  17.  
  18.     Welcome();
  19.  
  20.     enum mathType {Area, Volume, Perimeter};
  21.  
  22.     mathType Math;
  23.     int x;
  24.  
  25.     cout << "What math type would you like?(0-2) Area is 0, Volume is 1, and Perimeter is 2.\r\n";
  26.     cin >> x;
  27.     Math = mathType(x);
  28.  
  29.     if (Math == Area)
  30.         {
  31.             if (!cin.good())
  32.                 {
  33.                 cout << "Invalid Character, please input an integer.\r\n";
  34.                 return 1;
  35.                 }
  36.  
  37.             cout << "Enter Width then Length:" << "\r\n";
  38.             cin >> Width;
  39.             cin >> Height;
  40.             cout << "Area is:" << Width * Height << endl;
  41.         }
  42.  
  43.  
  44.     if (Math == Volume)
  45.         {
  46.             if (!cin.good())
  47.             {
  48.                 cout << "Invalid Character, please input an integer.\r\n";
  49.                 return 1;
  50.             }
  51.  
  52.             cout << "Enter Width, then Height, then Base:\r\n";
  53.             cin >> Width;
  54.             cin >> Height;
  55.             cin >> Base;
  56.             cout << "Volume is:" << Width * Height * Base << endl;
  57.         }
  58.  
  59.     if (Math == Perimeter)
  60.     {
  61.         if (!cin.good())
  62.         {
  63.             cout << "Invalid Character, please input an integer.\r\n";
  64.             return 1;
  65.         }
  66.  
  67.         cout << "Enter Width, then Length.\r\n";
  68.         cin >> Width;
  69.         cin >> Height;
  70.  
  71.         Width2 = Width * 2;
  72.         Length2 = Height * 2;
  73.  
  74.         cout << "Perimeter is:" << Width2 + Length2 << endl;
  75.     }
  76.  
  77.     return 0;
  78.  
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement