Question
Asked by:
nalani63
nalani63
Rating : No Rating
Questions Asked: 2
Tutorials Posted: 0
 

$15.00 methods in java

Q:
This is in Java. Cannot use any Math classes
Should have a driver for each method

Write a public static method named wholePart that takes a double as its argument and returns a double that is just the whole part of the number (that which is on the left side of the decimal point).

Write a public static method named validScore that takes a double as its argument and returns the argument only if it is between 0 and 100 inclusive. If the argument does not meet that specification, a console window print statement should state that an error condition exists and ask for a valid number, which should be then returned if valid. import java.util.Scanner;is already present in your program in the right place.

Write a public static method named chunk30 that takes a double and returns an integer that represents the number of chunks of 30 in that number. A chunk of 30 is 30, or any part thereof. For example, given the following arguments, the returned value would be:
60 returns 2, 15 returns 1, 91.2 returns 4, 0.17 returns 1, etc.
 


   
   
   
   
 
Available Tutorials to this Question
Posted by:
b_h
b_h
Rating (671): A+
Questions Asked: 0
Tutorials Posted: 1188, earned $24,653.40
 

$15.00 Help with Java Methods

  • This tutorial was purchased 1 time and hasn't been rated yet.
  • Posted on Feb 14, 2009 at 11:12:41PM
A:
Preview: ... now if you ...

The full tutorial is about 11 words long plus attachments.

Attachments:
Driver.java (1K) (Preview)
Posted by:
rainman
rainman
Rating (40): A+
Questions Asked: 2
Tutorials Posted: 174, earned $906.64
 

$10.00 Java Methods. Detailed Comments. Compiled and Works.

  • This tutorial was purchased 1 time and hasn't been rated yet.
  • Posted on Feb. 15, 2009 at 12:03:16AM
A:
Preview: ... score and return it. <br> return validScore(score);<br> <br> }<br> <br> public static int chunk30(double chunk)<br> {<br> //i is the number of chuncks of 30<br> int i = 0;<br> <br> //While chunk is greater than zero we will keep<br> //subtracting 30 from it. We add the number of times 30 is<br> //subtracted from it by incremeting i. i is the final asnwer. <br> <br> while (chunk > 0)<br> {<br> chunk -= 30;<br> i++;<br> }<br> <br> return i;<br> } <br> <br> public static void main(String[] args)<br> {<br> //Make a new Scanner<br> input = new Scanner(System.in); <br> <br> //Tests for the first function wholePart;<br> System.out.println( "The whole part of 123.45 is " + wholePart(123.45) );<br> ...

The full tutorial is about 1197 words long plus attachments.

Attachments:
Methods.java (3K) (Preview)
   
Join Now or Log In
Get Tutoring
Get Paid
Academic Honesty