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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!