Question: JAVA: Write a program that will take one string of four positive integers (e.g. 0 1 1 2) and will test to see if there
JAVA:
Write a program that will take one string of four positive integers (e.g. 0 1 1 2) and will test to see if there are two pairs present in the string. This will be implemented by the IntPairs object. This object will have a constructor that takes no arguments and the following two methods:
public void setPairString(String str) - will take a string as an argument & then store it in an instance variable.
public boolean hasTwoPairs() - will return true when there are only two pairs present in the string.
-You can use a Scanner on a string as well as System.in. It works the same way but the constructor takes a string rather than System.in.
-When done with the scanner, be sure to call the {scanner variable name}.close() You are free to make local variables.
-You can use them to hold the numbers you get from the string. **create two classes: IntPairs.java(source file) and main.java (for test code)
I have this code but it doesn't work... if possible can you make a completely new way of code in solving this problem pls thank you

import java.util.* public class IntegerPairs private String pairString; public IntegerPairs0 public void setPairString(String str) ( public boolean hasTwoPairs() intl arr new int[4]; Scanner sin new Scanner(pairstring); for (int i = 0; i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
