如何使用MOD计算一个盒子中适合的物品数量? [英] How to calculate how many items will fit in a box using MOD?

查看:78
本文介绍了如何使用MOD计算一个盒子中适合的物品数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力完成我的学校项目,但我陷入了最后一个过程。我需要打印总价格和盒子的数量以及每个的价格。用户需要输入他想要的咖啡袋数量,每袋需要1000个,并且有3个盒子可以装入,一个大盒子装20个袋子,中盒子装10个袋子,一个小盒子装5袋咖啡。每箱的成本分别为5000,3000和1000。我知道我需要使用MOD来确定每个盒子里会有多少,但说实话我甚至不知道从哪里开始!救命?这就是我到目前为止所做的:



我尝试了什么:



案例D:

案例d:

double bolsas = 0;

double Cg = 5000;

double Cm = 3000;

double Cp = 1000;

double precioxB = 1000;

double precioBolsas = 0;

System.out.println(Cuantas bolsas desea ordenar?);

bolsas = sc.nextInt();

precioBolsas = bolsas * precioxB;

I am trying to finish my school project but I am stuck in the last process. I need to print the total price and the amount of boxes and the price of each. The user needs to input how many bags of coffee he wants, each bag costs 1000, and there are 3 boxes to pack them in, a large box fits 20 bags, medium box fits 10 bags and a small box fits 5 bags of coffee. Each box costs 5000,3000 and 1000 respectively. I know I need to use MOD to determine how many will go in each box but to be honest I dont even know where to start! Help? This is what I've done so far:

What I have tried:

case "D":
case "d":
double bolsas=0;
double Cg=5000;
double Cm=3000;
double Cp=1000;
double precioxB=1000;
double precioBolsas=0;
System.out.println("Cuantas bolsas desea ordenar?");
bolsas=sc.nextInt();
precioBolsas=bolsas*precioxB;

推荐答案

作为一名程序员,掌握这种数学是你工作的一部分,这是一项非常需要的技能。

与你在现实中发现的相比,这个问题甚至都不复杂。



建议:

- 拿一张纸,一支铅笔画一张桌子

用#包制作栏目,从1开始继续

用#大盒子制作栏目

make column使用#media box

使用#小盒子制作栏目

为每个袋子找到最佳解决方案。 查找模式。你会发现不需要MOD。



然后检查没有陷阱:

得到20袋

如果您只购买1种大小或中等或小型的盒子,费用是多少。



该程序将遵循这些模式。
As a programmer, mastering this kind of mathematics is part of your job, it is a really needed skill.
This problem is not even complicated compared to what you will find in reality.

Advice:
- Take a sheet of paper, a pencil draw a table
make column with # bags, start at 1 an go on
make column with # large boxes
make column with # medium boxes
make column with # small boxes
find the best solution for each # of bags. find patterns. You will see that there is no need of MOD.

Then check that there is no trap:
get 20 bags
what is the cost if you take only 1 kind of boxes, large or medium or small.

The program will follow these patterns.


这篇关于如何使用MOD计算一个盒子中适合的物品数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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