User Profile

Collapse

Profile Sidebar

Collapse
mygolfcircle
mygolfcircle
Last Activity: Mar 2 '08, 01:08 PM
Joined: Feb 14 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • mygolfcircle
    replied to Non static variable
    in Java
    Any suggestions on how i should modify the code so as to not violate oo principles?
    See more | Go to post

    Leave a comment:


  • mygolfcircle
    started a topic Non static variable
    in Java

    Non static variable

    Can someone pls help ? How do I get my global variables destinationCity Code, numberOfAdults and isReturn to be populated with values from the user ?
    I will need them for calculations in to be passed to other methods later. Thanks in advance... pls help.

    Code:
    import java.util.*;
    import java.text.*;
    import java.math.*;
    import java.io.*;          // Access System.out
     
    public class MyBooking
    ...
    See more | Go to post

  • mygolfcircle
    replied to Rounding up a float value
    in Java
    I did indeed figure it out by testing. :)


    System.out.prin tln("Lastly, enter Number of Hours.");
    numberOfHours = Math.ceil(in.ne xtDouble());
    intHours = (int)numberOfHo urs;

    Because we had to accept a double, I converted the ceiling value to an int.
    See more | Go to post

    Leave a comment:


  • mygolfcircle
    replied to Rounding up a float value
    in Java
    I'm pretty sure the ceiling() method is my answer. Any hints? :)
    See more | Go to post

    Leave a comment:


  • mygolfcircle
    replied to Rounding up a float value
    in Java
    I'm sorry. I have indeed confused the class with the package.

    However, i am still unsure how to find the nearest higher integer when a float is
    passed into the function.

    I'm still new to java, so i'll have to re-look the methods. :(
    See more | Go to post

    Leave a comment:


  • mygolfcircle
    replied to Rounding up a float value
    in Java
    I'd like to believe that the java.math API could actually assist, and have been experimenting with the nextUp() and round() methods. However, each time i try to use one of these, i get a method - class not found error in my script.

    i HAVE imported java.math.* previously at the start of the code.

    What are the probable causes of method - class not found? I am on 1.6 by the way.
    See more | Go to post

    Leave a comment:


  • mygolfcircle
    replied to Rounding up a float value
    in Java
    Hi there!

    Thanks for the reply, however, could anyone be kind enough to provide the actual code to complete the following :

    float x;
    x = 3.1417;

    //syntax to round float x upwards to 4
    x = ......

    Thanks fellas.
    See more | Go to post

    Leave a comment:


  • mygolfcircle
    started a topic Rounding up a float value
    in Java

    Rounding up a float value

    Hi everyone,

    I'd like some help to round UP a float value to the nearest higher integer.
    This means,

    1.2 will be rounded up to 2
    2.15 will be rounded up to 3
    4.01 will be rounded up to 5
    9.47 will be rounded up to 10 etc etc

    I think the functions to use lie somewhere in the math class, but i'm not sure how to manipulate the methods available therein.

    Please...
    See more | Go to post
No activity results to display
Show More
Working...