H Biz

Greenhorn
+ Follow
since Apr 19, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by H Biz

Matthew Brown wrote:No, it doesn't. Multiplication has higher precedence than addition. The addition of those brackets doesn't have an effect.



Ahh I forgot about bodmas, true. Well is there a chance that his payrate is being multiplied by the overtime before it has a chance to multiply the overtime hours?
12 years ago
Your math is wrong buddy.

it should be:

if (hours > max_hours)
{
wages = ((max_hours * payRate) + (((hours - max_hours) * payRate) * overtime))

your way works out the standard hours

(max_hours * payRate)

adds it to

(hours - max_hours)

then times it all by the pay rate

then times it all again by the overtime


my way works out the standard max hours wage, then works out the overtime, then adds them together
12 years ago

Wilson Oluwasegun wrote:Hello, I'm new to java and still don't understand the true functions of if and while statements and why the greater than sign(>) and less than signs(<) are introduced as well as this types : beerNum = beeNum - 1;
i'm so eager to understand java. Would really appreciate your help.



If statements are just like real life if statements.

If somethings is <insert outcome: true/false/higher/lower>
then do X
else do Y

So a real world example:

If day is a week day
then: go to work
else: stay at home

If phone rings
then: answer call
else: leave alone

> greater than
and
< less than
signs, are used to compare items - especially useful in if conditions.

if chocolate bar price is less than change in my pocket
then: buy
else; dont buy

if chocolateBarPrice < pocketChange
then: buy
else: null - i think thats correct


A while loop is used when something needs to continually happen until a condition is met to stop/break the loop.

For example:

While bank balance is greater than $50
buy beer
else: go home

becomes

While bankBalance > 50
buy beer
bank balance - 5
else: go home

Im a noob to so just read up on what I say - I may be wrong too
12 years ago
Hey Everyone and thank you for reading this post.

Okay so I am currently coding this project in BlueJ, here is what I have so far:

I have 5 classes thus far:
-Film : which I have got to create a film object which includes the films (title, director, release year and duration) ... I will want it to be able to get these details from reading a text film rather than manual input at some stage.

-Show: The show takes the film and creates a show, a show consists of the films duration plus the ad duration (currently 20 minutes) and round up to the nearest hour. Showings are either 2, 3, 4 or 5 hours long. My current setup is to store the show time limits in an array in reverse order, i then have a for loop which runs as many times as there are instances in the array. This takes the array value i.e. 120 for 2 hours and minus' the sum of the film and ad duration. If its >= 0 it stores the value of the array item into a variable named showDuration. - is there a cleaner way?

I also have empty classes at the moment: Show Schedule, Screen and Cinema.
-showschedule creates a schedule from the shows
-screen selects a schedule
- cinema displays films on show plus creates screens
!!! I also need to create a class to handle seat bookings

My issues at the moment are this:

It is required that the class Show returns the film information ( title, director, release year and duration - 2 String and 2 int).
I don't know if I should be storing the values of the film object within the show object from when the show object is being created (duplication / efficiency issues here perhaps?)
How do I return 2 different types of values at once without using the to string command.
Orrr do I somehow reference the film object initially used to create the show object and use a method call on the film object to return the values?

so far I have this accessor method ...

public Film getFilmDetails()
{
// to be completed
}

A final issue for now is forward thinking. I want to be able to create a new cinema object which automatically generates the 4 screens which


Please can you help me out, Im not expecting code but some thoughts on the issues I have raised and some learning materials would be hugely beneficial

HBiz
12 years ago