rendered paste body#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main() {
//Begin declaring variables
double num_first_cat;
string first_cat;
int num_second_cat;
string second_cat;
int first_cat_length;
int second_cat_length;
double first_ratio;
double second_ratio;
int ratio_length;
//End variable declaration
cout << fixed;
//Begin inputs
cout << "How many in the first category.." << endl;
cin >> num_first_cat >> first_cat;
cout << "How many in the second category.." << endl;
cin >> num_second_cat >> second_cat;
//End inputs
//Begin defining length of categories
first_cat_length = first_cat.length();
second_cat_length = second_cat.length();
ratio_length = first_cat.length() + second_cat.length() + 2;
//End defining length of categories
//Begin creating singular items
string first_cat_singular = first_cat.substr(0,first_cat_length-1);
string second_cat_singular = second_cat.substr(0,second_cat_length-1);
//End creating singular items
//Begin ratio calculations
first_ratio = num_first_cat/num_second_cat;
second_ratio = num_second_cat/num_first_cat;
//End ratio calculations
//Begin outputs
cout << setprecision(0); //To display no decimal points in the num_first_cat (because it is a double for the ratio to be a double)
cout << setw(ratio_length) << first_cat << ": " << setw(10) << num_first_cat << endl;
cout << setw(ratio_length) << second_cat << ": " << setw(10) << num_second_cat << endl;
cout << setprecision(2); //To display 2 decimal points.
cout << setw(ratio_length) << first_cat_singular << "-to-" << second_cat_singular << " ratio " << setw(10) << first_ratio << endl;
cout << setw(ratio_length) << second_cat_singular << "-to-" << first_cat_singular << " ratio " << setw(10) << second_ratio << endl;
//End outputs
return 0;
}