Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-09-2008, 02:30 AM
Member
 
Join Date: May 2008
Posts: 4
Nine0joe is on a distinguished road
Need help with constructing code
i need to design and implement an application that reads an integer value and prints the sum of all even intergers between 2 and the input value, inclusive. i also want to print an error message if the input value is less than 2 and i want to promt the user accordingly.

Any help will be greatly appreciated THANKS. =)
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-09-2008, 02:38 AM
Member
 
Join Date: May 2008
Posts: 4
Nine0joe is on a distinguished road
Also i need to know where to find the toolkits. This is an assignment for school and i downloaded ecplise, but cannot find toolkits so i can use keyboardreader, and this is what i have so far i dont know how to finish it
Code:
public class Projects { public static void main(String[] args) { KeyboardReader temp = new KeyboardReader(); double V; List<Double> valueList = new ArrayList<Double>(); // You can store the values in here While (V = temp.readdouble("Enter a Value of 2 or more: ") ); { if (V >2){ valueList.add(V); // just added the value to a list } else { System.out.println("Value must be of 2 or more, Please restart the program!!"); } } } }
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-09-2008, 02:42 AM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 251
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
Code:
int evennumbers = 0,total=0; int input = new java.util.Scanner(System.in).nextInt(); while(evennumbers < input){ total += (evennumbers += 2); }
Try to test the code.

You can add if statement to ensure that the user inputs 2 or more....
You can play with JOptionPane.
__________________
best regards,
sukatoa

Last edited by sukatoa : 05-09-2008 at 02:46 AM.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-09-2008, 02:46 AM
Member
 
Join Date: May 2008
Posts: 4
Nine0joe is on a distinguished road
You want me to include that into my code or do it separately? And do you know where to find the toolkits at?
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 05-09-2008, 02:52 AM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 251
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
Ofcourse, how will you realize if you just watch it and not by testing from it....

And also, i like to confirm if that was what you like to implement.
What toolkit are you looking for? What should be the use of that?

Im not an eclipse user. But many are using eclipse here...
__________________
best regards,
sukatoa
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 05-09-2008, 02:55 AM
Member
 
Join Date: May 2008
Posts: 4
Nine0joe is on a distinguished road
haha, well we use that in my school. i forgot to bring a copy of took kits on my flash drive. I need the toolkits that have the keyboard reader, math, and all that.. i dont know if you could help me with that lol
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 05-09-2008, 03:14 AM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 251
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
I think that toolkit is used for catching keyboard inputs.

What about Scanner?

That keyboard reader should be a type of class that uses either a Scanner class, byte conversion, or Streams.

@My first reply, Do it separately and have some experiments from it....
__________________
best regards,
sukatoa
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I need help fixing my code.. or non code? MrHuggykins New To Java 1 03-19-2008 11:12 PM
Pls some one to help mi wit this code _nik_ New To Java 3 02-10-2008 03:02 AM
code help chitwood New To Java 0 02-10-2008 01:08 AM
help with oop code nhlfan New To Java 1 11-27-2007 09:21 PM
Generating Code Automatically Using Custom code Template In Eclipse JavaForums Eclipse 1 04-26-2007 04:52 PM


All times are GMT +3. The time now is 06:28 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org