Question
JAVA My program takes in a file that contains intervals separated by semicolons. For example: 1, 15; 16, 30 1, 10; 11, 20; 21, 30
JAVA
My program takes in a file that contains intervals separated by semicolons. For example:
1, 15; 16, 30
1, 10; 11, 20; 21, 30
1, 5; 6, 10; 11, 15
1, 3; 4, 6; 7, 9; 10, 12
1, 12; 13, 24
I need to go through each line and see if an input variable is contained in that line's intervals. For example, if I am looking at the first line of the file
1, 15; 16, 30
I have two intervals, (1, 15) and (16, 30). If my input variable is 7, then it belongs to the first interval (1, 15).
My question is, what is the easiest way to go through each line and make it so that I can turn that line into actual interval variables I can compare my input variable to? And how do I do that when some lines contain more than two intervals?
Any help is extremely appreciated!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started