Here is what I have so far. When I run the code I am getting the correct number of letters however It is outputting in a straight line instead of a reverse triangle pattern.
import java.util.*;
import java.io.*;
class Main {
public static void main(String[] args) throws IOException {
Scanner f = new Scanner(new File("labA21.dat"));
while (f.hasNext()) {
triangleTwo(f.nextInt(), String.format(""+ f.next().charAt(0)));
}
}
/**
Description: output a reverse triangle given a number of rows and a letter
@param r a number of rows
@param let a letter that we want to output
*/
public static void triangleTwo(int r, String let) {
for (int a=r;a>=1;a==) {
for (int b=1;b<=a;b++)
System.out.println(let);
System.out.println();
}
System.out.println();
}
}
What I'm getting:
A
A
AA
AA
What I'm supposed to get:
AAA
AA
A