Output all combinations of character variables a, b, and c, in the order shown below. If a = 'x', b = 'y', and c = 'z',

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Output all combinations of character variables a, b, and c, in the order shown below. If a = 'x', b = 'y', and c = 'z',

Post by answerhappygod »

Output all combinations of character variables a, b, and c, in the order shown below. If a = 'x', b = 'y', and c = 'z', then the output is:
xyz xzy yxz yzx zxy zyxNote: If outputting multiple character variables with one statement, the argument for System.out.print() should start with "" +
Your code will be tested in three different programs, with a, b, c assigned with 'x', 'y', 'z', then with '#', '$', '%', then with '1', '2', '3'.
import java.util.Scanner;
public class OutputCombinations {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
char a;
char b;
char c;
a = scnr.next().charAt(0);
b = scnr.next().charAt(0);
c = scnr.next().charAt(0);
/* Your solution goes here */
System.out.println("");
}
}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply