Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.50 KB | None | 0 0
  1. /*----------------------------------+
  2. +     Programmer : Anas Douma       +
  3. +         Course : CS-1             +
  4. +         Sectio : 0115             +
  5. +     Assignment : Program 4        +
  6. +       Due Date : 7 April 2017    +
  7. +----------------------------------*/
  8.  
  9. #define _USE_MATH_DEFINES
  10.  
  11. #include <iostream>
  12. #include <iomanip>
  13. #include <string>
  14. #include <cmath>
  15.  
  16. using namespace std;
  17.  
  18. int main()
  19. {
  20.  
  21.     int i, k;
  22.     double min, max, degree = 0, rad, tempdegree = 0;
  23.     cout << fixed << showpoint << setprecision(1);
  24.  
  25.     cout << "Anas Douma - Computer Science 1 - Program 4\n\n" << "This program will generate tables of tangents.\n" << "(To terminate, enter a number which, when rounded is >= 90 or < 0 )" << endl << endl;
  26.     cout << " ***     ***     ***     ***     ***     ***     ***     ***     ***     ***  " << endl << endl;
  27.     cout << "Minimum and maximum values for left coulumn of table : ";
  28.     cin >> min >> max;
  29.     cout << endl;
  30.  
  31.  
  32.     min = (int(min * 10.0 + 0.5)) / 10.0;
  33.     max = (int(max * 10.0 + 0.5)) / 10.0;
  34.     while (min >= 0 && min < 90 && max >= 0 && max < 90) {
  35.         if (max < min) {
  36.             double temp = min;
  37.             min = max;
  38.             max = temp;
  39.         }
  40.  
  41.         cout << "                        Partial Table of Tangents\n" << "          0      1      2      3      4      5      6      7      8      9\n"; // I want to change it to setw();
  42.         cout << "      ----------------------------------------------------------------------" << endl;
  43.  
  44.         for (i = 0; degree < max; i++) {
  45.             degree = (min + (i / 10.0));
  46.             cout << setprecision(1) << degree << " | ";
  47.             for (k = 0; k < 10; k++) {
  48.                 tempdegree = degree + (k / 100.0);
  49.                 rad = tan(tempdegree * (M_PI) / 180);
  50.                 if (rad < 10)
  51.                     cout << setprecision(4) << rad << " ";
  52.                 else {
  53.                     if (rad < 100)
  54.                         cout << setprecision(3) << rad << " ";
  55.                     else {
  56.                         if (rad < 1000)
  57.                             cout << setprecision(2) << rad << " ";
  58.                         else
  59.                             cout << setprecision(1) << rad << " ";
  60.                     }
  61.                 }
  62.             }
  63.             cout << endl;
  64.         }
  65.  
  66.         cout << "      ----------------------------------------------------------------------" << endl;
  67.         cout << endl;
  68.  
  69.         cout << "***   ***   ***   ***   ***   ***   ***   ***   ***   ***   ***" << endl << endl;
  70.         cout << "Minimum and maximum values for left coulumn of table : ";
  71.         cin >> min >> max;
  72.         cout << endl;
  73.         min = (int(min * 10.0 + 0.5)) / 10.0;
  74.         max = (int(max * 10.0 + 0.5)) / 10.0;
  75.         tempdegree = 0;
  76.         degree = 0;
  77.     }
  78.     cout << " *** Table generation has been halted *** " << endl;
  79.     cin.get();
  80.     return(0);
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement