User Profile
Collapse
-
Any suggestions on how i should modify the code so as to not violate oo principles? -
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
-
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.Leave a comment:
-
I'm pretty sure the ceiling() method is my answer. Any hints? :)Leave a comment:
-
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. :(Leave a comment:
-
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.Leave a comment:
-
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.Leave a comment:
-
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...
No activity results to display
Show More
Leave a comment: