• Post Reply Bookmark Topic Watch Topic
  • New Topic

Set Operations  RSS feed

 
shawn wong
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi~~
From Input.Txt file to read
input.txt Content
A{1,2,3,4,5}
B{32,34,56,78}
C{12,3,4,5,}
user keyboard input (A-B)*C Or((A*B)-c)+b
+(||),-(&&),*(difference)

Thanks
 
Campbell Ritchie
Marshal
Posts: 56529
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch

There is nothing like a nice short question, but that one is maybe too short!

Do you mean, how do you do set operations like intersection difference and union? Go to the Java Tutorials, and you can read about the collections framework, which includes sets. There is an interface called Set, and it tells you which method represents union, intersection, etc. You can then call the same method on a class which implements the Set interface; HashSet is probably the most popular. For some versions of set difference you may have to do the procedure in several stages.

Good luck with it
 
Bill Shirley
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a nice homework problem, however we suggest you Do Your Own Homework (FAQ).

Aside:
I've always thought professors would be better off giving early program assignments with code that performs the I/O already and input test files, so that new programmers can see some code and learn from it, and modify the code to do the crux of the work. Later in the term they can get the I/O part dumped on them.

Get some of it going, and if you have particular questions about your code as us.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!