I have to write a program that outputs all possible permutations for three input strings. My code works fine except for one problem: if I put a space in between words, it takes the second word as a second input string. How could I use the following code but allow for blank spaces?
// Chapter 2 programming exercise 17) // Program to give all six permutations for 3 inout strings import java.util.*; public class Ch2_PrExercise17 { public static void main(String[] args) { Scanner console = new Scanner(System.in); //variable declaration String a, b, c, aa, bb, cc, dd, ee, ff; //executable expressions System.out.println("This program will allow you to input three phrases and it will give you all the permutations."); System.out.println("Please press Enter after each entry."); System.out.println(); System.out.println("Enter the first phrase: "); a = console.next(); System.out.println(); System.out.println("Enter the second phrase: "); b = console.next(); System.out.println(); System.out.println("Enter the final phrase: "); c = console.next(); System.out.println(); //calculations aa = a + " " + b + " " + c; bb = a + " " + c + " " + b; cc = b + " " + a + " " + c; dd = b + " " + c + " " + a; ee = c + " " + a + " " + b; ff = c + " " + b + " " + a; //output requirements System.out.println(aa); System.out.println(bb); System.out.println(cc); System.out.println(dd); System.out.println(ee); System.out.println(ff); } }