Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Java Methods code. Someone help please

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Objective

You will write a program called Methods.java. It will define a number of public static methods, as described below.
Required Methods

add
takes two doubles, returns their sum
max
takes two doubles, returns the larger value (3.0 is larger than -10.0)
rev
takes a String, returns the reversed String ("Hi, Bob" reversed is "boB ,iH")
pi
takes nothing, returns exactly 3.14159
store
takes a double, remembers it, returns nothing
recall
takes nothing, returns the last double from store
even
takes an int, returns true or false if it’s even or not
iota
takes an int (let’s call it n), returns an array of n ints containing 1001, 2002, 3003, ..., n*1001.
Assume that n > 0.
sum
takes an array of doubles, returns their sum
mean
takes an array of doubles, returns their mean (total divided by how many). It must call the sum method to calculate the total. Assume that the array is non-empty.




Testing

We will not call your main. In fact, you don’t even have to provide a main, though you certainly should use one for testing. You must provide a class called Methods that contains the methods described above. We will call your functions in various ways, from our own code. Our testing will not be limited to the code provided below.

If you don’t manage to write all of the methods, write what you can, and get points for what you got done.
Test Code

Here’s a main that you might find useful to test your methods:




If someone who actually likes programming that wants to do this assignment for me then you should
Thanks in advanced
 
bill pahceco
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay i've done some of them. Im not sure how to do the methods:

rev
store
recall
iota
sum
mean

This is what I have so far:

 
Can you really tell me that we aren't dealing with suspicious baked goods? And then there is this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic