Calculate and return the sum of the geometric series

Assignment Help JAVA Programming
Reference no: EM13852171

To complete this homework assignment, turn in m-files containing the MATLAB code that you generate in response to each problem. Functions should be turned in in separate files. A single script m-file should be turned in. This file should include all scripts that you generate in response  to the problems. In cases where you generate a function in response to the problem, the script fileshould call  this function to demonstrate that it works. Use comments in the script file to indicate which problem each portion of the file is responding to.
1. Write a function repvec that receives a vector and the number of times each element is to be duplicated. The function should then return the resulting vector. Here are some examples of calling the function:

>>repvec(5:-1:1,2)
>>repvec([0 1 0],3)
2. Vectorize the following code:
n = 3;
x = zeros(n);
y = x;
for i = 1:n
x(:,i) = i;
y(i,:) = i;
end
3. Using vectorized code, write a function called geomser that will receive values of r and n and will calculate and return the sum of the geometric series:
1 + r + r2 + r3 + ... + rn
The following examples of calls to this function illustrate what the result should be:
>>geomser(1,5)
>>geomser(2,4)

Reference no: EM13852171

Questions Cloud

Identify the advantages and disadvantages of circuit switch : Identify the advantages and disadvantages of circuit switching and packet switching-X.25, Frame Relay, Asynchronous Transfer Mode2, and Transmission Control Protocol/Internet Protocol (TCP/IP)-regarding performance, speed and throughput potential, an..
Identify strategies for continuing your literature review : Read the second information sheet on ‘Literature Reviews: Staying on Track' to identify strategies for continuing your literature review, and ‘putting it all together'
Review a case for an arson investigation : An insurance company has asked your digital forensics firm to review a case for an arson investigation. The suspected arsonist has already been arrested, but the insurance company wants to determine whether there's any contributory negli- gence on th..
Write all the contents of a java file : Write all the contents of a Java file named 'Restaurant.java'. This file contains the class Restaurant that represents some data about a Restaurant.Every Restaurant is identified by its 3 attributes: a category (like "Chinese" or "Mediterranean"), a ..
Calculate and return the sum of the geometric series : calculate and return the sum of the geometric series
Comprehensive assessment of the 2014 financial statements : The final project for XACC 290 is a 700- to 1,050-word paper in which you provide a comprehensive assessment of the 2014 financial statements of Tootsie Roll Inc. You will focus on assessing the company's Balance Sheet and Income Statement
Describe charge transfer mechanisms in a voltage doubler : Describe the charge transfer mechanisms in a voltage doubler, and show that the output terminal voltage is twice the peak of the input AC source voltage. How would you reverse the polarity of the output voltage in such a circuit?
How are the business and the technology perspectives : Identify in which phase of the development process - How are the business perspectives and the technology perspectives of an informations system related.
Respective velocities of points : Respective velocities of points A (bottom of the wheel), B (top of the wheel) and C (rearmost point of the wheel). Respective accelerations of points A, B and C on the wheel as indicated.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Project is for designing and developing a college

project is for designing and developing a college registration program. write a java program to register students for a

  The continual rise in popularity of php as a solution

Question: With the continual rise in popularity of PHP as a solution to e-commerce applications and the tendency to protect intellectual property, just how open do you think the future will be as far as Web application development is concerned? For t..

  Note the line number in the statement

Note the line number in the statement

  Balancing binary search trees

Balancing Binary Search Trees,  Consider the file BST.java (a link to this file is provided below for downloading purposes) which defines a generic Binary Search Tree class.

  Representing an investment value and interest rate

Write a Java test program, all your code should be in the main method that asks the user for two numbers representing an investment value and interest rate.

  Implement a simple number guessing game using html forms

Your assignment is to implement a simple number guessing game using HTML forms and a Java servlet. The HTML page should introduce the game and provide a form for the user to guess a number on. The servlet should use an HTTP session object to store..

  Create a program using a gui interface

In your lab5 folder, compile the file that is a starting point for this assignment. The listing and image of this Java class is on the bottom of this lab description. You can create the programs by cutting and pasting.

  Determine the number of quarters

Read in a sum of money and determine the number of quarters, dimes, pennies and nickels represented in the cents portion.  You must get an optimal mix; all pennies, for example, is not allowed.

  Design a java program that simulates a slot machine

Design a java program that simulates a slot machine. When the program runs, it should do the following: Ask the user to enter the amount of money he or she wants to insert into the slot machine. ? Instead of displaying images, the program will random..

  Minimal spanning tree decreasing edge dismissal

Minimal Spanning Tree Decreasing Edge Dismissal, Reverse-delete algorithm. Develop an implementation that computes the MST

  Finding java code error

Indicate in the given code segment if an error occurs. If so, point to whether it is syntax, runtime or logic and how you would fix it.

  Create and implement class called date to store month

Create and Implement the class called Date which has data members to store month (as a number), day, year, and name of month.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd