Clothes size calculation-衣服尺寸计算

Clothes size calculation-衣服尺寸计算

//Clothes size calculation
#include<iostream>
double get_capsize(double weight,double height);
double get_jecketsize(double height,double weight,int age);
double get_waistline(double weight,int age);
int main()
{
    using namespace std;
double height,weight;
int age;
double capsize,jecketsize,waistline;
    char ans;
    
do
{
    cout<<"Enter the height,the weight and the age :\n";
    cin>>height>>weight>>age;
    capsize = get_capsize(weight,height);
    jecketsize = get_jecketsize(height,weight,age);
    waistline = get_waistline(weight,age);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);
    cout<<"The size of cap is "<<capsize<<endl;
    cout<<"The size of jecket is "<<jecketsize<<endl;
    cout<<"The size of waist is "<<waistline<<endl;
    
    cout<<"Do you want again?";
    cin>>ans;
}while('y' == ans || 'Y' == ans);
return 0;
}
double get_capsize(double weight,double height)
{
    return (weight/height)*2.9;
}
double get_jecketsize(double height,double weight,int age)
{
    if(age <= 30)
        return 1.0*(height * weight)/288;
    //else
        return 1.0*(height * weight)/288 + ((age - 30)%10)*(1.0/8); 
}
double get_waistline(double weight,int age)
{
    if(age <= 28)
        return weight / 5.7;
    //else
        return weight / 5.7 + ((age - 28)%2)*(1.0/10);
}

结果:

Enter the height,the weight and the age :
69 185 50
The size of cap is 7.78
The size of jecket is 44.32
The size of waist is 32.46
Do you want again?y
Enter the height,the weight and the age :
67 200 58
The size of cap is 8.66
The size of jecket is 47.53
The size of waist is 35.09
Do you want again?

利用身高、体重、年龄计算帽子、上衣以及腰围尺寸。

你可能感兴趣的:(计算,衣服尺寸)