Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help answering question 9.1 to 9.6. I would much appreciate the assistanc

ID: 3720166 • Letter: I

Question

I need help answering question 9.1 to 9.6. I would much appreciate the assistance.

for loop infinite loop midpoint break loop nested loops OBLEMS 9.1 Use a for loop to sum the clements in the following vector: x [, 23, 43, 72, 87, 56, 98, 33] Check your answer with the sum function. Repeat the previous problem, this time using a while loop. Usc a for loop to create a vector of the sine of values from 0 to 9 radians with an increment of 1 Use a while loop to create a vector of the sine of values from 0 to 9 radian with an increment of 1. Use the linspace function to create a vector from 1 to 24. Now use a for loop to add the nth number from the beginning and from the end. For example, the first 6 numbers are 9.2 9.3 9.4 9.5 1 2 3 4 5 6 Your calculation would be Which gives 9.6 A Fibonacci sequence is composed of elements created by adding the wo previous elements. The simplest Fibonacci sequence starts with 1 proceeds as follows: 1, 1, 2, 8, 5, 8, 1 hapter 9 Repetition Structures population of mosquitoes in thi found using this formula: s area at any given point of time can be where Pa is the current population, is the rate of growth, which is equal to 0.65, and t is time in months. At t - 0, population is 10,000. Using a for loop, make a vector of the population from 0 to 24 months. Plot this vector as a function of time. The daily dose of a medicine taken by an elderly person is determined by the percentage of change in his blood pressure level. The doctor has given him a prediction table for the change in percentage of his blood pressure level for 10 days: 9.11 Change [11 -10 19 20 5 -12 11 16 18 19 100 mg, calculate his daily dosage of th

Explanation / Answer

Q1)Using for loop to sum the elements in the vector.

Answer)

Implemented the below program in Java for the above requirement.

import java.util.*;   

class VectorImpl{   

public static void main(String args[]){   

Vector<Integer> v=new Vector<Integer>(); // declaring the vector

int result=0; // result variable

v.add(1); // adding the elements one by one

v.add(23);

v.add(43);

v.add(72);

v.add(87);

v.add(56);

v.add(98);

v.add(33);

for (int i=0;i<v.size();i++){ // for loop for sum of the elements in the vector and their sum stored into result

result=result+v.get(i);

}

System.out.println(result); // printing the sum

}   

}   

Ouput:

413

Here the for loop used is:

or (int i=0;i<v.size();i++){

result=result+v.get(i);

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote