Hi, Im new to java and have been issued my first assignment, ive coded my menu and am beginning to code my first sub section of the menu which is a character patter printer, basically what it does is prompts the user to enter the ammound of rows and the character they would like to use.
please enter number of rows : 5
please enter a character : c
output :
c
cc
ccc
cccc
ccccc
i cant figure out how to get the character to appear on the line more then once. here is my code for when the user selects a, bare in mind that i am new and this is my first assignment and loops may nit be the correct way to go about it, but its all i could think of with what i've learned so far
// Menu selection A, character pattern, will ask user
// for number of rows and a character to enter
if (menuChoice == 'A' || menuChoice == 'a'){
// If a number exceeding 25 is entered, the loop wont allow
// the program to continue untill a number between 1 - 25
// is entered
while (patternRows > 25) {
System.out.println("Welcome to Character pattern printing");
System.out.println("Please enter # of Rows (max 25)");
System.out.print("Wont allow a number higher than 25 : ");
// Taking user response and storing it in the
// variable patternRows
patternRows = scanner.nextInt();
}
System.out.print("Please enter a character : ");
patternChar = charInput.readLine().charAt(0);
while (linesPrinted != patternRows){
System.out.println(patternChar);
linesPrinted ++;
}