Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 16th, 2004, 05:45 PM
Metroid Metroid is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 1 Metroid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Help With Basic Java(Just Starting Out)

Well, I am just starting out with learning Java, and I was doing this excercise. The point was to make a program that

class Example4
{
public static void main ( String[] args )
{
double x, value;
x = 2/3 ;
System.out.println("Answer is:" + (3*(x*x)- 8*x + 4));
}
}


Now, the next excercise says this:

Modify the program in exercise 2 so that one run of the program will evaluate and write out the value of the quadradic for three different values of X: 0.0, 2.0, and 4.0 (or any three values of your choice.)

Write the program using only two variables, probably called x and value. Of course this means that you will have to put different things in these variables in different places in the program.


Now I have no idea how to do this. Can anyone help me out. Thanks.

Reply With Quote
  #2  
Old July 17th, 2004, 12:42 PM
kode_monkey kode_monkey is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 367 kode_monkey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 21 sec
Reputation Power: 6
I would advise you to start by making a function that computes the quadratic based on any given input for x and returns the answer. Then call that function with your values asigning the answer to value after each and printing it.

-KM-

Reply With Quote
  #3  
Old July 20th, 2004, 03:50 PM
Sharon White Sharon White is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Location: London
Posts: 4 Sharon White User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
class Example4
{

public static void main ( String[] args ){
System.out.println("Answer is:" + evaluate(0.0));
System.out.println("Answer is:" + evaluate(2.0));
System.out.println("Answer is:" + evaluate(4.0));
}

double evaluate(double x){
return (3*(x*x) - 8*x + 4);
}

}

_____________________________________________________
Sharon White

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > Help With Basic Java(Just Starting Out)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway