Quantcast

Maximum PC

It is currently Sat Dec 20, 2014 6:46 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 58 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject:
PostPosted: Mon Mar 16, 2009 6:29 pm 
Little Foot
Little Foot
User avatar

Joined: Mon Jul 28, 2008 1:39 pm
Posts: 123
Does that above code still not work?

And btw, I got that "march of progress" thing off of Cay Horstmann's website. You may not be familiar with him, but if you are taking an AP Computer Science course, you will be familiar with his work by the end of the year. You see, Mr. Horstmann had the honor of implementing the AP CS "GridWorld" case study. You will either love it or hate it. Here's hoping you'll love it, 'cause I hated it :(


Top
  Profile  
 
 Post subject:
PostPosted: Tue Mar 17, 2009 1:35 am 
Northwood
Northwood
User avatar

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2261
Location: No. 1 Thread Killer
Quertior wrote:
Does that above code still not work?

And btw, I got that "march of progress" thing off of Cay Horstmann's website. You may not be familiar with him, but if you are taking an AP Computer Science course, you will be familiar with his work by the end of the year. You see, Mr. Horstmann had the honor of implementing the AP CS "GridWorld" case study. You will either love it or hate it. Here's hoping you'll love it, 'cause I hated it :(


Oh it works, but I feel like it's the least efficient manner possible.


Top
  Profile  
 
 Post subject:
PostPosted: Tue Mar 17, 2009 6:18 am 
Little Foot
Little Foot
User avatar

Joined: Mon Jul 28, 2008 1:39 pm
Posts: 123
Well for what you're doing, efficiency shouldn't really matter, as long as you're not doing something like
Code:
for(int i=0; i<1000000;i++) {}
//useful code...


Top
  Profile  
 
 Post subject:
PostPosted: Wed Mar 18, 2009 4:24 pm 
Northwood
Northwood
User avatar

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2261
Location: No. 1 Thread Killer
Why that is true. Quert, can you look at my code I have and tell me where my test array is doing me wrong?

Code:

// Program By Dwood
// Version: 3.18.09
removed




If test[index] = zero then heatIndex[index] is supposed to equal temps[index]

I'm not getting that. Gah I hate this program D:


Last edited by Dwood15 on Fri Jul 31, 2009 12:39 pm, edited 2 times in total.

Top
  Profile  
 
 Post subject:
PostPosted: Wed Mar 18, 2009 5:12 pm 
Northwood
Northwood
User avatar

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2261
Location: No. 1 Thread Killer
nevermind:


Code:

      for(index=0; index < 12;)
      {
              if(temps[index] > 80) //notice the swap
                 {
                 test[index] = false; //notice the swap
                 }
             else if(humids[index] > 60)  //notice the swap
                 {
                 test[index] = false;  //notice the swap
                 }   
             else
                {
                test[index] = true; //notice the swap
                 }
         
         
   if (test[index] = false)  //notice the swap
      {
      < Heat Index Equation here >
      heatIndex[index] = heatindex;
      } // end of if statement
   else
      {
         heatIndex[index] = temps[index];
      }
   index++;
      }



Something funky is amiss! Btw... initially when I reordered the original code that didn't help much :/ The changes only happened when I reversed the boolean operators.

<Program fixed!>


Top
  Profile  
 
 Post subject:
PostPosted: Wed Mar 18, 2009 5:19 pm 
Little Foot
Little Foot
User avatar

Joined: Mon Jul 28, 2008 1:39 pm
Posts: 123
Once again, good job.


Top
  Profile  
 
 Post subject:
PostPosted: Wed Mar 18, 2009 5:24 pm 
Northwood
Northwood
User avatar

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2261
Location: No. 1 Thread Killer
Quertior wrote:
Once again, good job.


Actually... It turns out the output is now either ALL temps or ALL heatIndex... BAH!


Top
  Profile  
 
 Post subject:
PostPosted: Tue Mar 24, 2009 3:40 pm 
Northwood
Northwood
User avatar

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2261
Location: No. 1 Thread Killer
OH man I hate this. All right so I have a circle whose radius can be anything as long as it is a relative of 1 (100, 10, 1, .01, .1 etc)

r^2 = x^2 + y^2 right?

Well I need to find the points on a circle given an increment of x, so x could be .90 (radius 1) so 1 = .81 + y^2

1 - x = .19
sqrt .19 = .44

I hate circles so much.

I just do.


Top
  Profile  
 
 Post subject:
PostPosted: Tue Mar 24, 2009 5:21 pm 
Northwood
Northwood
User avatar

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2261
Location: No. 1 Thread Killer
Haaaaah Wow I'm retarded.

I forgot to use my Round method in the program.

Now it looks like things are perking up!

Code:
// Points On A Circle Version 1
// Dwood
// I have no idea what I am doing eh.
// Assume that the circle is at x = 1; y =1;

removed




Try that on for size. That's also how I should have made my other one look. Probably not the most robust program but eh I had fun. We'll see what happens.


Last edited by Dwood15 on Mon May 11, 2009 3:23 pm, edited 1 time in total.

Top
  Profile  
 
 Post subject:
PostPosted: Thu Apr 23, 2009 3:59 pm 
Northwood
Northwood
User avatar

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2261
Location: No. 1 Thread Killer
Code:
most removed

public static double[] gravity( double mass[], double e[])
    {

   
     return grav;   
     
    }
       
       
    public static void main(String[ ] args)
    {
   
        double[]  grav = gravity(mass[], diameter[]); //What's the problem


I'm confused right now...


Last edited by Dwood15 on Mon May 11, 2009 3:24 pm, edited 1 time in total.

Top
  Profile  
 
 Post subject:
PostPosted: Thu Apr 23, 2009 7:51 pm 
Little Foot
Little Foot
User avatar

Joined: Mon Jul 28, 2008 1:39 pm
Posts: 123
The problem is, array variable names are referenced the same way as normal variable names. So you would say:
Code:
double grav[] = gravity(mass, diameter);


Top
  Profile  
 
 Post subject:
PostPosted: Sun Apr 26, 2009 4:44 pm 
Northwood
Northwood
User avatar

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2261
Location: No. 1 Thread Killer
here's a new one though.
[code]Removed
[code]

REMOVED [/code]


Grav[] turns out to be 0 no matter what. It's bugging me.


Last edited by Dwood15 on Mon May 11, 2009 3:26 pm, edited 2 times in total.

Top
  Profile  
 
 Post subject:
PostPosted: Sun Apr 26, 2009 7:42 pm 
Little Foot
Little Foot
User avatar

Joined: Mon Jul 28, 2008 1:39 pm
Posts: 123
Try writing out 0.0000000000667 instead of 6.67E-11 .


Top
  Profile  
 
 Post subject:
PostPosted: Mon Apr 27, 2009 12:53 pm 
Northwood
Northwood
User avatar

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2261
Location: No. 1 Thread Killer
Quertior wrote:
Try writing out 0.0000000000667 instead of 6.67E-11 .


Turns out that the for loop, less than operator in my gravity equation was really a greater than operation.

I have bolded it in my post to make it easier to find now.


Top
  Profile  
 
 Post subject:
PostPosted: Sun May 03, 2009 4:45 pm 
Northwood
Northwood
User avatar

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2261
Location: No. 1 Thread Killer
Code:
      int decimalOwed = (int)((amtOwed - (int)amtOwed) * 100); //Intify for easier calculation
            
   }


If I change decimalOwed to a double it's like 35.99994 or something...

Turns out I just need to add .5 and THEN cast it as an int.

Edited out most of the code because I'm submitting it in a bigger project.


Top
  Profile  
 
 Post subject:
PostPosted: Sun May 03, 2009 5:59 pm 
Little Foot
Little Foot
User avatar

Joined: Mon Jul 28, 2008 1:39 pm
Posts: 123
Looks like you solved your own problem. Good job.


Top
  Profile  
 
 Post subject:
PostPosted: Mon May 04, 2009 2:06 pm 
Northwood
Northwood
User avatar

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2261
Location: No. 1 Thread Killer
Quertior wrote:
Looks like you solved your own problem. Good job.


What bothers me is that amt owed is only 2 decimals back and multiplying 100 to it should therefore make the decimals 0. This is not the case. (in Java, anyways)


Top
  Profile  
 
 Post subject:
PostPosted: Thu May 14, 2009 3:14 pm 
Northwood
Northwood
User avatar

Joined: Sun Jul 15, 2007 6:37 pm
Posts: 2261
Location: No. 1 Thread Killer
Sweet... So I'm onto REAL OOP.

:) This is interesting because I never thought of programming in Java this way... Looks like I still have a LONG ways to go :3 Eventually this course will be over and I'll be looking for more.


Top
  Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 58 posts ]  Go to page Previous  1, 2, 3

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

© 2014 Future US, Inc. All rights reserved.