简体   繁体   English

计算每次使用的价格

[英]Calculating price per use

How would you work out the price per use of an item - in my case an exercise bike -您如何计算每次使用物品的价格 - 在我的情况下是健身自行车 -

A) Total cost / number of uses A) 总成本/使用次数

or或者

B) Total cost halved per use B) 每次使用的总成本减半

and how would this be done in code (Javascript specifically google sheet scripting) Right now none of my code is even beginning to come close to the two potential answers Right now its 6 uses (value automatically changes in H1 of my spreadsheet) and cost of $40 Currently i think it should be done the way B says and this is my attempt but its not giving me the expected output and i have tried a few other methods however the division within the for loop doesn't seem to get repeated even when i have only had one line.以及这将如何在代码中完成(Javascript,特别是谷歌工作表脚本)现在我的代码甚至都没有开始接近两个潜在的答案 现在它的 6 种用途(值在我的电子表格的 H1 中自动更改)和成本40 美元目前我认为它应该按照 B 所说的方式完成,这是我的尝试,但它没有给我预期的输出,我尝试了其他一些方法但是 for 循环中的除法似乎没有重复,即使我只有一行。

I have removed many of the var definitions just to make the post cleaner我删除了许多 var 定义只是为了使帖子更干净

newppr = new price per ride newppr = 每次骑行的新价格

ppr = price per ride ppr = 每次骑行的价格

oldppr - old price per ride oldppr - 每次乘车的旧价格

pob = price of bike pob = 自行车的价格

var numofRides = SpreadsheetApp.getActiveSheet().getRange('H1').getValue(); //gets number of rides from cell H1
for (i = 0; i <= numofRides; i++) {
  oldppr = pob / 2; 
  newppr = oldppr / 2;
  newppr = newppr / 2;
  ppr = newppr;
}
SpreadsheetApp.getActiveSheet().getRange('F3').setValue(newppr);   //sets new value to cell F3 
}

Am i making this over complicated and which should it be - if its A then its an easy fix but i have some doubt about which one it is any help will be gratefully received我是不是把它弄得太复杂了,应该是哪一个 - 如果它是 A 那么它是一个简单的解决方案,但我对它是哪一个有一些疑问,任何帮助将不胜感激

Total cost/number of uses" also generates a flat rate/use but it requires an estimate of the total number of uses. Say your bike could survive 1000 uses, then $40/1000 = $0.04cents per use, and that would be a pricing policy that might apply to commodity-type products"总成本/使用次数”也会产生固定费率/使用,但它需要估计使用的总次数。假设您的自行车可以使用 1000 次,那么 $40/1000 = $0.04cents 每次使用,这将是一个定价可能适用于商品类产品的政策"

Thanks to Tedinoz for the response, this is the exact information I couldn't find and thank you for your time感谢 Tedinoz 的回复,这是我找不到的确切信息,感谢您的时间

Just for a bit of clarification, Its a bike I already have and want to justify the price of due to financial reasons alongside some nice stats on my personal tracking spreadsheet.只是为了澄清一下,它是我已经拥有的自行车,并且出于财务原因想要证明其价格以及我个人跟踪电子表格上的一些不错的统计数据。 Your final comment is the best it's just instead of the $40 / 1000 it will be my current number of uses so there is no need for code to attempt to half the cost for each use!您的最终评论是最好的,它不是 40 美元 / 1000 美元,而是我当前的使用次数,因此无需代码尝试将每次使用的成本减半! Turns out I was really overthinking this and it is just a simple cell / cell.原来我真的想多了,它只是一个简单的单元格/单元格。 Many many thanks.非常感谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM