Write a method called sigma

Assignment Help JAVA Programming
Reference no: EM13691692

Question 1) Write a method called sigma that takes an int parameter n and returns the sum of all the integers from 1 to n (inclusive). For example, sigma(4) should return 10.

Question 2) Write a method called distance that takes four double parameters, x1, y1, x2 and y2. x1 and y1 are the coordinates of the first point; x2 and y2 are the coordinates of the second point. The method should return the distance between the two points. Use the Pythagorean theorem.

Question 3) The hailstone sequence begins with some designated integer n (it can be any integer). If n is even, then the next number in the sequence is n/2. If n is odd, then the next number in the sequence is 3 * n + 1.

Write a method called hailstone that takes an int parameter that gives the starting place. The method should return the number of steps that it takes until the sequence arrives at 1. For example: if the method is called with 3 as the parameter, then the sequence would be 3, 10, 5, 16, 8, 4, 2, 1. It takes 7 steps to get from 3 to 1, so the method would return 7.

Please show me all the work and provide me the code.

Reference no: EM13691692

Questions Cloud

Is it likely that both ring connections are mad : Problem- Is it likely that both ring connections are mad simultaneously in this experiment (Miniscale synthesis of a substituted pyrimidine) as was observed for the diels-alder synthesis
What prymidine would be expected as the product starting : Problem- What prymidine would be expected as the product starting with acetamidine and diethyl malonate? with urea and 2,4-pentanedione. Depict your all calculation in detail so I can understand the solution thoroughly
Calculates the average of numbers : Write a C program which takes n number of element from user (where, n is specified by user), stores data in an array and calculates the average of those numbers. Output of the program should look like this;
How many moles of strong base were initially added : Assume that the volume remains constant when the base is added. when the reaction is complete, what is the concentration ratio of conjugate base to acid. How many moles of strong base were initially added
Write a method called sigma : Write a method called sigma that takes an int parameter n and returns the sum of all the integers from 1 to n (inclusive). For example, sigma(4) should return 10.
Calculate the change in internal energy : Calculate the change in internal energy of the following system: a 100.0-g bar of gold is heated from 25 ?C to 50 ?C during which it absorbs 322 J of heat. Assume the volume of the gold bar remains constant.
List the six steps in the problem solving methodology : List the six steps in the problem solving methodology described in the text to be applied to computer programming assignments?
Calculate the number of joules in a btu : Problem- The use of the British thermal unit (Btu) is common in much engineering work. ABtu is the amount of heat required to raise the temperature of 1 lb of water by 1?F. Calculate the number of joules in a Btu.
What mass of naoh is needed to precipitate the cd2+ ions : Problem- What mass of NaOH is needed to precipitate the Cd2+ ions from 34.0mL of 0.510M Cd(NO3)2 solution

Reviews

Write a Review

JAVA Programming Questions & Answers

  String copy and string concatenation functions

Write the string copy and string concatenation functions -  Append n characters from string2 to stringl by using pointer arithmetic

  Create a computer class

Create a computer class and assume computers have the following fields: String manufacture, double price, int year

  Write a program called word guessing game.

Write a program called Word Guessing Game. Open the file FourLetterWords.txt and write the contents into an array of Strings (the file has 87 words in it).

  Create application uses two-dimensional arrays

Create an application which uses 2-dimensional arrays to keep track of 5 students' grades, with each student having 3 different classes.

  Inheritancedemo

Create a New Project named InheritanceDemo . 2. Create a new class called Person and cut and paste the Person.java file from Blackboard into the class. Create a new class called Student and cut and paste the Student.java file from Blackboard into the..

  Explain how a typical ide is used explain the purpose of

explain how a typical ide is used. explain the purpose of the various panes of the ide. justify the importance of this.

  Java program by array

Write a program that reads in a file that contains one integer per line. Each integer represents one location in the image. Assume that there are 64 rows and 64 columns in the image

  Create the working applet to compute tax

Write down a java applet. Your applet assits to find out how much federal tax we require to pay suppose the tax rate is 12%. Create and implement the working applet to compute tax.

  Write a program that displays a frame window w pixels wide

Write a program that displays a frame window W pixels wide and H pixels high. Use the Scanner to enter the values for W and H. The title of the frame is also entered by the user.

  Describe the basic c syntax for creating a class comprise

explain the basic c syntax for creating a class. include an explanation of the private and public section of a class

  Design an object-oriented java application

You are to design an object-oriented Java application to let the user play a dice game that uses two dices. The player bets on a value and the dices roll

  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.

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