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

  Write a java statement to have the object from manage

Write a Java statement to have the object from manage its display area by dividing it into 3 rows which have 4 columns each.

  Create a console-based program and a gui application

Create a console-based program and a GUI application, which justifies the following conditions: The Main() method prompts the user for an integer value and, in turn.

  Writing a simple gui application using a class called myguic

writing a simple GUI application using a class called MyGuiClass. Your GUI will have a JButton which your program will need to respond to when it is clicked. Describe what you would need to do to setup event handling using a nested inner class. Use J..

  Build a thread system

Identify all Nachos classes that you will modify and where you plan to do you modifications - Identify all classes that you plan to implement and give the API for each class,

  Java socket hello i need to this assignment done in net

hello i need to this assignment done in net beans . and i want comment in code .also screen shots of running program

  Recommend at least five factors which programmers must

propose at least five factors that programmers should consider when choosing between data types such as those used in c

  Record managing system application

Build a student record managing system application

  Write a program to register students for a college students

write a program to register students for a college. students have names addresses and courses. implement the interface

  All your code should be in the main method

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

  Method called wordlengths that accepts a scanner

Write a method called wordLengths that accepts a Scanner representing an input file as its argument. Your method should read from the given file.

  Implement the application using a singly linked list

Implement the following application using a singly linked list. This application accepts from console and stores a list of 10 names of your friends in the singly linked list

  Write program using a switch statement that display polygon

Write a program using a switch statement that displays the name of a polygon with sides between 3 and 12 depending on the number entered by the user

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