Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Nick Ku PIC10A Intro. to Programming
- ID: 304491540 Spring 2016
- Email: cinestra@ucla.edu HW #3
- Section: 3A
- Honesty Pledge:
- I, Nichokas Ku, pledge that this is my own independent work, which conforms to
- the guidelines of academic honesty as described in the course syllabus.
- List of none bugs: None.
- */
- #include<iostream>
- #include<iomanip>
- #include <string>
- using namespace std;
- int main(){
- int n1;
- int n2;
- string first_category;
- string second_category;
- cout << "How many in the first category? ";
- cin >> n1 >> first_category;
- cout << "How many in the first category? ";
- cin >> n2 >> second_category;
- cout << setw(10) << first_category << setw(10) << n1 << endl;
- cout << setw(10) << second_category << setw(10) << n2 << endl;
- double a;
- a = n1;
- double b;
- b = n2;
- double ratio1;
- ratio1 = a / b;
- double ratio2;
- ratio2 = b / a;
- string s1;
- s1 = first_category + "-to-" + second_category + "ratio";
- string s2;
- s2 = second_category + "-to-" + first_category + "ratio";
- cout << fixed;
- cout << setprecision(2) << setw(10) << s1 << " " << setw(10) << ratio1 << endl;
- cout << setprecision(2) << setw(10) << s2 << " " << setw(10) << ratio2 << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement