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 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...
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.
In Coral Code Please!!!! The assignment is to get an integer from input, and output that...
In Coral Code Please!!!! The assignment is to get an integer from input, and output that integer squared, ending with newline. (Note: This assignment is configured to have students programming directly in the zyBook. Instructors may instead require students to upload a file). Below is a program that's been nearly completed for you. Click "Run program". The output is wrong. Sometimes a program lacking input will produce wrong output (as in this case), or no output. Remember to always pre-enter...
Hello! I'm trying to write a code that will either encrypt/decrypt a message from an inputed...
Hello! I'm trying to write a code that will either encrypt/decrypt a message from an inputed text. I'm having the absolute hardest time getting stared and figuring out how to identify in the code if the input needs to be encrypted/decrypted and identifying the string to encrypt/decrypt with. These are the instructions: Objectives Command line input File input and output Rethrowing exceptions Program Description Gaius Julius Caesar encoded his battle messages so that the opponent could not read them should...
Presume for a minute that (OK, so maybe this premise was slightly borrowed from the movie...
Presume for a minute that (OK, so maybe this premise was slightly borrowed from the movie The Stepfather, the one from the 1980s, not the terrible recent one), a new college professor moves into town and gets a job teaching math. The new professor is charming and funny and everyone likes him. The dean introduces him to his daughter and they begin an engagement. Shortly thereafter, he begins acting possessive and increasingly paranoid. He begins staying after class, very late...
Among a sample of 16 people, the average heart rate was 69.0 beats per minute with...
Among a sample of 16 people, the average heart rate was 69.0 beats per minute with a standard deviation 4.3 beats per minute. We are interested in the mean heart rate of the population. We assume that the heart rate is normally distributed, and that the population standard deviation is 4.8 beats per minute. At 95% confidence, what is the error bound?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT