微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何计算加工中的速度-距离-时间?很想举个例子

如何解决如何计算加工中的速度-距离-时间?很想举个例子

我就是这样做的,但是我不知道如何使用公式。我正在尝试创建一个健身速度和速度计算器。但是说到公式,我就迷失了。

int a = 5;
int b = 2;
a *= b;  // Sets 'a' to 10.

我知道应该是这样的吧?但我似乎无法理解如何计算它的公式。如果有人可以请查看我的代码,看看在哪里以及如何放置公式?

String myText = "Type"; 

int value = 0;
String myText1="TYPE",myText2="TYPE",myText3="TYPE",myText4="TYPE"; 

int selText=0; 

void setup() { 

  size(800,800); 

  textSize(40);
} 

void draw() { 

  background(0,187,250); 
  textSize(40);
  fill(0);
  text("Pace and Speed Calculator",150,40);

  //outer Box
  rect(50,50,700,700);

  //top Box
  fill(204);
  rect(75,70,650,350);

  //bottom Box
  fill(225);
  rect(75,400,350); 

  //Initial data

  //time Box
  textSize(40);
  fill(0);
  text("Time",350,125);

  //Ttile HOURS
  textSize(32);
  fill(0);
  text("Hours:",125,185);

  //Title Minutes
  textSize(32);
  fill(0);
  text("Minutes:",250);

  //Title Seconds
  textSize(32);
  fill(0);
  text("Seconds:",315);

  //Title distance
  fill(0);
  text("distance:",375);

  textSize(20);
  fill(0);
  text("metres(m)",415,375);

  //To tell user to double to enter
  textSize(25);
  text("Click the Box to enter",425,250);

  //Speed Box
  textSize(32);
  fill(0);
  text("Speed:",550);

  textSize(20);
  fill(0);
  text("kilometres per hour",550);

  //Pace Box
  textSize(32);
  fill(0);
  text("Pace:",650);

  textSize(20);
  fill(0);
  text("min/km",650);

  //Button  
  fill(255);
  rect(550,325,50);
  fill(0);
  textSize(32);
  text("Calculate",555,360);

  //time Boxes 
  fill(255);

  rect(260,140,50); 

  rect(260,215,50);

  rect(260,280,345,515,615,50);

  fill(255,0); 

  text(myText1,260,185); 

  text(myText2,250); 

  text(myText3,315); 

  text(myText4,380);

  //time Boxes

  fill(0); 

  if (selText==1) { 

    myText1= myText; 

    text(myText1,185);
  } else if (selText==2) { 

    myText2= myText; 

    text(myText2,250);
  } else if (selText==3) { 

    myText3= myText; 

    text(myText3,315);
  } else if (selText==4) { 

    myText4= myText; 

    text(myText4,380);
  }
}

void mouseClicked() { 

  if (mouseX>260 && mouseX<500 && mouseY>170 && mouseY<200) { 

    myText = myText1; 

    selText = 1;
  } else if (mouseX>260 && mouseX<500 && mouseY>230 && mouseY<260) { 

    myText = myText2; 

    selText = 2;
  } else if (mouseX>260 && mouseX<500 && mouseY>270 && mouseY<320) { 

    myText = myText3; 

    selText = 3;
  } else if (mouseX>260 && mouseX<500 && mouseY>330 && mouseY<390) { 

    myText = myText4; 

    selText = 4;
  } else { 

    selText = 0;
  } 

  if (value == 0) {
    value = 255;
  } else {
    value = 0;
  }
}


void keypressed() { 

  if (keyCode == BACKSPACE) { 

    if (myText.length() > 0) { 

      myText = myText.substring(0,myText.length()-1);
    }
  } else if (keyCode == DELETE) { 

    myText = "";
  } else if (keyCode != SHIFT && keyCode != CONTROL && keyCode != ALT) { 

    myText = myText + key;
  }
}

解决方法

首先,a *= ba = a*b 相同。

您的输入是小时、分钟、秒和距离(米),您的输出是速度(公里/小时)和步速(分钟/公里),单位是您的公式。

因此,您将需要以小时为单位的时间值、以分钟为单位的时间值和以公里为单位的距离值。

  float timeHours = hours + minutes/60 + seconds/3600;
  float timeMinutes = hours*60 + minutes + seconds/60;
  float distanceKM = distance/1000;

  // Speed = km/h
  float speed = distanceKM/timeHours;
  // Pace = min/km
  float pace = timeMinutes/distanceKM;

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。