Question

In: Computer Science

So, I'm trying to get an average revolutions/minute from an input vector. Here's a sample vector:...

So, I'm trying to get an average revolutions/minute from an input vector.

Here's a sample vector:

V=[10200 11000 11800 12300 13100 13900 14400 15020 15850 16250]

The units are in ms so 10200 is 10.2 seconds.

The revolutions is between every successive value. So 11000 - 10200 is 1 revolutions per 800 ms and et cetera.

I need help figuring out a code that will allow me find the average cadence from the whole dataset.

Thank you in advance

Solutions

Expert Solution

Program :-

import java.util.Scanner;

public class VectorQ {

   public static void main(String[] args) {
       Scanner scan = new Scanner(System.in);
       System.out.print("Enter number of sample vector data : ");
       int data = scan.nextInt();
      
       int i;
       float timeSum = 0f;
       int revolution =0;
       float result;
      
       System.out.println("Enter sample vector data : ");
       int[] v = new int[data];
       for(i=0; i<data; i++)
       {
           v[i] = scan.nextInt();
       }
      
       for(i=1; i<data; i++)
       {
           timeSum += (v[i] - v[i-1]);
           revolution++;
       }
      
       timeSum = (timeSum/1000f);
      
       result = (revolution/timeSum) * 60;
      
      
       System.out.println("average rate = " + (int)result + " revolution/minute");

       scan.close();
   }

}


Related Solutions

So, I'm trying to get revolutions/second from a given binary data. for example, the input binary...
So, I'm trying to get revolutions/second from a given binary data. for example, the input binary data is: V=[0 1 0 0 1 0 0 0 1 0 1 1 0 0 0 0 0 1 0 ] let's say the distance between each value is arbitrary (for this example, you can use 0.1). Each 1 represents a full rotation of a bike pedal, and I'm trying to calculate the pedal rate from a given binary dataset in Matlab. How...
Javascript array of objects: I'm trying to get the input into an array of objects, and...
Javascript array of objects: I'm trying to get the input into an array of objects, and then display the information in a table using a for loop, but I don't think my path is right <!DOCTYPE html> <head> <title>Form</title> <meta charset="utf-8" /> <style media="screen"> h1 { text-align: center; } div { background-color: #pink; border: 2px solid green; padding: 15px; margin: 65px; } </style> <script> var list = []; total = 0; text = ""; function Product(item, quantity, costs){ this.item =...
I'm having trouble trying to create the italian, polish, and netherlands flag in C Here's my...
I'm having trouble trying to create the italian, polish, and netherlands flag in C Here's my code so far: #include<stdio.h> int main(){    int country_choice;    fprintf(stderr, "Enter the country_code of the chosen flag.(1 for Poland, 2 for Netherlands, 3 for Italy)");    fscanf(stdin, "%d", &country_choice);    switch (country_choice) { case 1: printf("Poland Flag\n"); printf("%c%c%c", 255,255,255); printf("%c%c%c", 220,20,60);    break;       case 2: printf("Italian Flag\n"); printf("%c%c%c", 0,146,70); printf("%c%c%c", 225,255,255); printf("%c%c%c", 206,43,55); break;    case 3: printf("Netherlands Flag\n"); printf("%c%c%c", 174,28,40);...
I'm having trouble with my do while loop. I'm trying to get it where if the...
I'm having trouble with my do while loop. I'm trying to get it where if the user enter's 3 after whatever amount of caffeinated beverages they've entered before then the loop will close and the rest of my code would proceed to execute and calculate the average price of all the caffeinated beverages entered. Can someone please help me with this? Here's my Code: import java.util.Scanner; public class Main { public static void main(String[] args) { CaffeinatedBeverage[] inventory = new...
I'm trying to get the union of two arrays and I tried making a loop that...
I'm trying to get the union of two arrays and I tried making a loop that does so. I tried also making the loop give me the size of the array as well from the union of the two arrays. Please check my loop to see what is wrong with it because it is not doing what I want it to do. I'm also not sure how to get the correct size of the array after the two arrays have...
I'm trying to make this C++ loan calculator but I can't get the program to output...
I'm trying to make this C++ loan calculator but I can't get the program to output what I need. For instance I know the formula is right and when I enter 100000 1.5 20 as my cin variables I should get 482.55 but I get 1543.31. What am I not seeing as the issue? Also this should cout only 2 decimal places right? I'm not allowed to alter the #include and add any fixed setprecision. This is what I have....
(C++) Hey, so I'm trying to make a Remove() and Add() function for a Binary Search...
(C++) Hey, so I'm trying to make a Remove() and Add() function for a Binary Search Tree (NOT USING RECURSION), can you help? For 3 cases: no child, 1 child and 2 children also for Remove(). This is the function to find the node to be deleted/added TreeNode* PrivateFind(const T& tWhat)    {        //Start from head        TreeNode* tWalk = mHead;        while (tWalk != nullptr)        {            //If found then return...
Write a driver to get a String input from keyboard and if the input string has...
Write a driver to get a String input from keyboard and if the input string has less than 10 characters, throw a StringTooShortException. public class StringTooShortException extends Exception {     //-----------------------------------------------------------------     // Sets up the exception object with a particular message.     //-----------------------------------------------------------------     public StringTooShortException()     {         super("String does not have enough characters");     } }
You have a dataset of the average number of chirps per minute for a sample of...
You have a dataset of the average number of chirps per minute for a sample of 30 crickets. You find that the mean number of chirps per minute is 40 and that the number of chirps per minute has a standard deviation of 5 chirps. You want to test that the mean number of chirps per minute for a cricket is greater than 38 using a significance level of .05. What is the value of your test statistic? Round your...
what is the calculated the average code using C++ Having a hard time trying to get...
what is the calculated the average code using C++ Having a hard time trying to get the float average.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT