All pastes #2045574 Raw Edit

Something

public text v1 · immutable
#2045574 ·published 2011-04-12 20:19 UTC
rendered paste body
#include <iostream>
#include <string.h>
#include <iomanip>

using namespace std;

int main() {
    
    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;
    
    cout << fixed;
    cout << setprecision(2);

    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;
    
    first_cat_length = first_cat.length();
    second_cat_length = second_cat.length();
    
    string first_cat_singular = first_cat.substr(0,first_cat_length-1);
    string second_cat_singular = second_cat.substr(0,second_cat_length-1);
    
    first_ratio = num_first_cat/num_second_cat;
    second_ratio = num_second_cat/num_first_cat;
    
    cout << first_cat_singular << "-to-" << second_cat_singular << " ratio " << first_ratio << endl;
    cout << second_cat_singular << "-to-" << first_cat_singular << " ratio " << second_ratio << endl;
    

    return 0;
}