Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*----------------------------------+
- + Programmer : Anas Douma +
- + Course : CS-1 +
- + Sectio : 0115 +
- + Assignment : Program 4 +
- + Due Date : 7 April 2017 +
- +----------------------------------*/
- #define _USE_MATH_DEFINES
- #include <iostream>
- #include <iomanip>
- #include <string>
- #include <cmath>
- using namespace std;
- int main()
- {
- int i, k;
- double min, max, degree = 0, rad, tempdegree = 0;
- cout << fixed << showpoint << setprecision(1);
- 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;
- cout << " *** *** *** *** *** *** *** *** *** *** " << endl << endl;
- cout << "Minimum and maximum values for left coulumn of table : ";
- cin >> min >> max;
- cout << endl;
- min = (int(min * 10.0 + 0.5)) / 10.0;
- max = (int(max * 10.0 + 0.5)) / 10.0;
- while (min >= 0 && min < 90 && max >= 0 && max < 90) {
- if (max < min) {
- double temp = min;
- min = max;
- max = temp;
- }
- cout << " Partial Table of Tangents\n" << " 0 1 2 3 4 5 6 7 8 9\n"; // I want to change it to setw();
- cout << " ----------------------------------------------------------------------" << endl;
- for (i = 0; degree < max; i++) {
- degree = (min + (i / 10.0));
- cout << setprecision(1) << degree << " | ";
- for (k = 0; k < 10; k++) {
- tempdegree = degree + (k / 100.0);
- rad = tan(tempdegree * (M_PI) / 180);
- if (rad < 10)
- cout << setprecision(4) << rad << " ";
- else {
- if (rad < 100)
- cout << setprecision(3) << rad << " ";
- else {
- if (rad < 1000)
- cout << setprecision(2) << rad << " ";
- else
- cout << setprecision(1) << rad << " ";
- }
- }
- }
- cout << endl;
- }
- cout << " ----------------------------------------------------------------------" << endl;
- cout << endl;
- cout << "*** *** *** *** *** *** *** *** *** *** ***" << endl << endl;
- cout << "Minimum and maximum values for left coulumn of table : ";
- cin >> min >> max;
- cout << endl;
- min = (int(min * 10.0 + 0.5)) / 10.0;
- max = (int(max * 10.0 + 0.5)) / 10.0;
- tempdegree = 0;
- degree = 0;
- }
- cout << " *** Table generation has been halted *** " << endl;
- cin.get();
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement