Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Set Operations

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 74754
336
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic