Roger Henthorn

Greenhorn
+ Follow
since Jun 06, 2014
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Roger Henthorn

Um.... unsure what the heck the urls are in my code that I pasted from my textpad?!?! They are most certainly not in my finished code...

only changes I made were:

Chapter12Driver Encrypt = new Chapter12Driver();

and the calling methods:

Encrypt.encrypt




9 years ago
I've updated my code--and now it works:





Sorry for the temporary brain fart in coding---its been a long weekend, and staring at code without taking breaks tends to make me glaze over the obvious.

went and made a White Russian---allowed me enough time to get a fresh set of eyes on the code. The Dude Abides........


Thanks!


9 years ago
So... I know this should work---however for the life of me I cant seem to access the class method to get my program working---keeps saying cannot find symbol " RogerHenthornChapter12.java:7: error: cannot find symbol
Chapter12Driver Encrypt = new Encrypt();"



Here is the file that I am trying to reference the encrypt variable from



any help would be most appreciated!

9 years ago
Doh! it should have been



instead of array, 10, occupiedRoom);


now what do I use for my if/else statement?


?



9 years ago
So....

Got some responses back between the Prof. and I and we both agree that my problem lies in my binary search algorithm.... Also need to make the binary search a method so this is what im thinking and what I have now:



This will ask for user input for the occupied hotel rooms---store them in an array and then sort the array using the Arrays.sort api.

The next part I have (this is in a file I named Utility.java)



This allows me to call Utility.binarySearch in my main---however now I'm having issues.... this is what I wanted to do (this is the code I want to have added in my main, right under the sort api call.



My thinking is I ask the user a room to search for---they enter it in and then the program calls the Utility.binarySearch to start searching for that number---im getting an ArrayIndexOutOfBoundsExeption: 4 error when I try to run the program (program lets me enter in the occupied rooms, and prompts me for the room to search for---errors out after that)

Im also kinda stuck (need coffee) about what to do next. I want it to look for that number, and if it finds it simply return the "Room is Occupied"--or if not "Room is Unoccupied". Would really think I could get away with the search setting a value like true or false and if its false print "Unoccupied" else "Occupied"........
9 years ago
Jelle,

I have to implement a binary search algorithm as part of the objective instead of using API calls.

Looks like the program is working---just not returning PRIME numbers when I search for the rooms.

Issue has to be in my binary search algorithm.....
9 years ago
AHA!!! Got it! Or at least the format for this site-----code is still broken HELP! Seems like this program doesnt like certain values as well...like "47" for instance. If i search for 47 it just returns a blank line---not "unoccupied"

9 years ago
That is HORRIBLE format---but if I paste it from textpad it comes out just like that---left hand justified.. Is there any way I can turn that off so I can post my code with correct formatting?
9 years ago
Taking my second class in java right now---last one was a year ago and due to some family circumstances I had to take a bit off from school.... So.. basically ive forgotten much between last year and now--so im reviewing and coding lessons at the same time !

Here is my issue:

This weeks problem has me code a program that asks for a hotel room number (s) with an exit code of -1. After the exit code is presented, the user is then asked for a room to search for. If this room is one that the user entered in the first place it reports the room as occupied. If the room was not entered (not in the array) it then reports as Unoccupied.

It compiles (previously had a break error---break outside of loop issue) and wouldn't compile (you will see where I commented these breaks out for now) Now I have an issue of endless loops..... Occupied, Occupied............. Frustrated!

Any Help would be greatly appreciated!

Here is my code so far:

Edit:
Noticed that some numbers return a loop--- if I enter in 50 and search for 50 it loops. Tired entering the following:

1
56
19
160
34
18
-1
and I search for 160
Returns occupied 6 times, then gives me an out of bounds error... So it seems that there is more wrong than I had originally thought
9 years ago