Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-09-2008, 01:30 AM
Member
 
Join Date: May 2008
Posts: 4
Rep Power: 0
Nine0joe is on a distinguished road
Default 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
  #2 (permalink)  
Old 05-09-2008, 01:38 AM
Member
 
Join Date: May 2008
Posts: 4
Rep Power: 0
Nine0joe is on a distinguished road
Default
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, 01:42 AM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 537
Rep Power: 2
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
Default
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.
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by sukatoa; 05-09-2008 at 01:46 AM.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-09-2008, 01:46 AM
Member
 
Join Date: May 2008
Posts: 4
Rep Power: 0
Nine0joe is on a distinguished road
Default
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, 01:52 AM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 537
Rep Power: 2
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
Default
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...
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 05-09-2008, 01:55 AM
Member
 
Join Date: May 2008
Posts: 4
Rep Power: 0
Nine0joe is on a distinguished road
Default
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, 02:14 AM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 537
Rep Power: 2
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
Default
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....
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

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

BB 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 10:12 PM
Pls some one to help mi wit this code _nik_ New To Java 3 02-10-2008 02:02 AM
code help chitwood New To Java 0 02-10-2008 12:08 AM
help with oop code nhlfan New To Java 1 11-27-2007 08:21 PM
Generating Code Automatically Using Custom code Template In Eclipse JavaForums Eclipse 1 04-26-2007 03:52 PM


All times are GMT +2. The time now is 12:16 AM.



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