<p>The link is given above, just post the answers or go over what you did.</p>
<p>Isn't anybody on CC a bit helpful??????</p>
<p>The link is given above, just post the answers or go over what you did.</p>
<p>Isn't anybody on CC a bit helpful??????</p>
<p>fine ill put the answers up let me write it up then :)</p>
<p>Here, i did this in 5 min flat so dont expect it to be perfect but i think this is something like what i did. I casted everything just in case (i.e. (Integer) )</p>
<p>public Reservation requestRoom(String guestName) {
for (int i=0;i<rooms.length;i++) {
if (rooms*==null) {
rooms* = new Reservation(guestName, i);
return rooms*;
}
}
waitList.add( String(guestName) );
return null;
}</p>
<p>public reservation cancelAndReassign(Reservation res) {
//WARNING, this function assumes that res is NOT a reference to rooms[] !! :)
int room<em>number = (Integer)res.getRoomNumber();
rooms[room</em>number]=null;
if (waitList.size()>0) {
rooms[room<em>number]=new Reservation( (String)waitList.remove(0), room</em>number );
return rooms[room_number];
}
return null;
}</p>
<p>also i thought they really fcked up when they didnt include what each method returns in the overview/index thing. -_-</p>
<p>I would post my answers, but I'm too busy cramming for Physics B, which is tomorrow.</p>
<p>But I'll try to post later, although I don't remember what I wrote.</p>
<p>Reviewing the code from the poster above, can you cast like that?
If you cast Integer, I think you have to unwrap it using ((Integer) res.getRoomNumber().intValue()).
Maybe I'm wrong, but Integers are objects, so to get the int stored in it, you have to unwrap it somehow.</p>
<p>blah time to study</p>
<p>michael, you're right.</p>
<p>private double average (int first, int last){</p>
<p>double sum;
double total = (last+1) - first;
for(int i = first; i<last; i++){
sum+=scores*;
}</p>
<p>return (double)(sum/total)</p>
<p>}</p>
<p>private boolean hasImproved(){</p>
<p>for(int i=1; i<scores.length(); i++){
if scores*<scores[i-1]
return false;
}</p>
<p>return true;</p>
<p>}</p>
<p>private double finalAverage()
{</p>
<p>boolean hasImproved;
if (hasImproved == true)
return average(scores.length()/2, scores.length());
if (hasImproved == false)
return average(0, scores.length());
}</p>
<p>I wrote this up quickly, could be wrong but I think this is what i wrote</p>
<p>yea opps i did that on the test, i jsut forgot to do that here.:)</p>
<p>Do they take off points if you made a mistake like putting "=" instead of "=="?</p>
<p>Also, what are the curves on this test?
60-80 a 5?????</p>
<p>yea probably thats kinda a big mistake :P (in syntax)</p>
<p>real comp sci ppl take the ab. our school requires it</p>
<p>confidential, dont get too cocky there, lots of us study by ourselves and dont have that kind of time to look at what in depth stuff we need for AB.</p>
<p>yea i thought comp sci a exam was pretty ez...my fr for the first one was realy close to opitsweirdisntit's, but i didn't cast for part b(don't think you had to rite?). Multiple choice was a lot easier than i thought, esp. after going over the Princeton Review book (yea pretty weird it got pretty low ratings, but i thought it helped me out more than Skylit's). About taking the AB test, i'm w/opitsweirdisntit...better off getting a 5 on A test than gettin' a 2 or a 3 on the AB test...mite as well take it over 2 years and get 2 5's over one 3.</p>
<p>my school doesn't even have computer science so i didn't want to take AB and not know what I was doing.</p>
<p>jabber, I disagree with several things. I thought the directions said that the average() method took the average from first to last INCLUSIVE, so I did for(int i = first; i<= last;i++), and then in the finalAverage() method, I sent it scores.length-1 (with no parenthesis...its an attribute of the array, not a method). Now i know that < length and <= length-1 are the same, but I just took inclusive to mean <= length-1. probably get full credit both ways.</p>
<p>confidential, do you go to TJ?</p>
<p>and way back up there, you cannot simply cast a primitive int to an Integer through (Integer). You must create new Integer objects with the value passed to the constructor. </p>
<p>So</p>
<p>arrayList.add(new Integer(i)) or something like that, k</p>
<p>Shahein's right for that and if something is inclusive i think you can just start i=0 i<watever because it <em>will</em> go through everything (i=0 & i=last)</p>
<p>Collegefreak:</p>
<p>If I remember correctly, the == or = mistake in conditional statements is not penalized...you just might not get full credit for a given problem. The grading rubrics ask for certain things and then award points for "correctness". You would probably get the "certain points", but not get maybe 1/2 for correctness.</p>
<p>hmm, interesting discussion :)</p>
<p>to the guy who asked for a sin function, here's something I've came up with in ~15 mins.</p>
<p>public double sin(double x)
{
double result=0;
for (int n=0; n<15; n++)
{
if (n%2 != 0)
result+=(Math.pow(x,(2<em>n+1)))/fact(2</em>n+1)<em>-1;
else result+=(Math.pow(x,(2</em>n+1)))/fact(2*n+1);
}
return result;
}</p>
<p>public int fact(int x)
{
if (x==0)
return 1;
else return x*fact(x-1);
} </p>
<p>this basically uses mclaurin series to calculate the value. (yes i did use pow from math library)<br>
works within .00000001 </p>
<p>now can we see yours ? :)</p>
<p>Yes. I wrote this in 1 min, after taking the Calc BC exam, with taylor fresh on my mind:</p>
<p>public static double sine(double x)
{
double xsquared = -1<em>x</em>x, last = x;
for(int i = 3; i <= 21; x+= last <em>= xsquared/((i</em>i-i), i+=2);
return x;
}</p>
<p>accurate to 10^-17 ;)</p>
<p>PS: you are wasting negative multiplicating and factorials</p>