C ++函数逻辑问题! [英] C++ function logic problem!

查看:67
本文介绍了C ++函数逻辑问题!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将某人的谷物重量从盎司转换为公吨,以及制造一公吨需要多少箱。我很擅长转换权重,我想知道我的函数中的逻辑是否正确并且正在按照它应该转换权重。如果不正确,有人可以告诉我这样做的语法和功能。谢谢!


#include< iostream>

使用命名空间std;


int main()

{

双倍Cereal_Weight,Cereal_Total,Total_Boxes;


cout<< 欢迎来到谷物转换器程序\ n;

cout<< 输入谷物盒的重量(以盎司为单位);

cin>> Cereal_Weight;


Cereal_Total = Cereal_Weight / 35273.92;

Total_Boxes = Cereal_Weight * 35273.92;


cout<< ; 你的谷物重量 << Cereal_Total<< "公吨\ n" ;;

cout<< 它需要 << Total_Boxes<< "填写一个公吨吨\ n" ;;


cin.sync();

cin.get();

返回0;

}

I''m trying to convert someones cereal weight from ounces to metric tons, and how many boxes it would take to make a metric ton. I suck at converting weights and I wanted to know if the logic in my function is correct and is converting the weights like it should be. If it is not correct can someone please tell me the syntax and function to do this. Thank You!

#include <iostream>
using namespace std;

int main ()
{
double Cereal_Weight, Cereal_Total, Total_Boxes;

cout << "Welcome to the cereal converter program\n";
cout << "Enter the weight in ounces of the cereal box\n";
cin >> Cereal_Weight;

Cereal_Total = Cereal_Weight / 35273.92;
Total_Boxes = Cereal_Weight * 35273.92;

cout << "Your cereal weighs " << Cereal_Total << " metric tons\n";
cout << "It would take " << Total_Boxes << " to fill a metric ton\n";

cin.sync();
cin.get();
return 0;
}

推荐答案

如果你可以用数学方法完成它,你可以简单地编程。首先编写一个函数算法或伪代码,然后简单地编写代码。请记住

1盎司= 2.83495231e-5公吨
If you can do it mathematically you can program it simply. Write a functional algorithm first or a pseudocode and then simply code it. Bearing in mind that
1 ounce = 2.83495231e-5 metric tons



如果你能用数学方法做到这一点你可以简单地编程。首先编写一个函数算法或伪代码,然后简单地编写代码。请记住

1盎司= 2.83495231e-5公吨
If you can do it mathematically you can program it simply. Write a functional algorithm first or a pseudocode and then simply code it. Bearing in mind that
1 ounce = 2.83495231e-5 metric tons



我不知道我是否知道怎么做在数学上,就像我说我不擅长转换重量而且我多年没做过。我试过谷歌搜索它,但我得到的只是转换器'转换它为我,所以如果有人可以告诉我,我的程序中的逻辑是否正确:35,273.92盎司一公吨/由输入的数字用户。


Cereal_Total = Cereal_Weight / 35,273.92;


逻辑是否正确如果没有,请告诉我这个功能应该是什么样的我可以转换它并继续前进。谢谢!

I don''t know if I know how to do it mathematically, like I said I''m not good at converting weights and I haven''t done it for years. I''ve tried googling it but all I get is converter''s that convert it for me, so if someone can tell me if my logic in my program is correct: 35,273.92 ounces in a metric ton / by the number entered by the user.

Cereal_Total = Cereal_Weight / 35,273.92;

Is the logic correct if not can you please tell me what the function should look like so i can convert this and move on. Thank You!


任何有帮助的人都会非常感谢你!
Anyone that could help would be great thank you!


这篇关于C ++函数逻辑问题!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆