Question: This program reads in a number R and a number C from the user, System.out.print(Enter Row: ); int R = kb.nextInt(); System.out.print(Enter Column: ); int
This program reads in a number R and a number C from the user,
System.out.print("Enter Row: "); int R = kb.nextInt();
System.out.print("Enter Column: "); int C = kb.nextInt();
int k, x; if(R>C) R=C; for(int i = 0; i<2*C-1; i++) System.out.print("$"); System.out.println(); // top line display k = ?; //Q1: =? x = ?; //Q2: =? for(int i = 1; i<=R-1; i++){ for(int j = 1; j<=k; j++) // k positions of $s System.out.print("$"); for(int j = 1; j<=x; j++) // x positions of blank space in between $-parts System.out.print(" "); for(int j = 1; j<=k; j++) // repeat same k positions of $s System.out.print("$"); System.out.println(); k = ?; // Q3: =? x = ?; // Q4: =? }
and displays a figure with R-rows and (2*C-1)-columns of "$" characters as the following pattern. For instance, if the user enters a 4 for R, and 6 for C, your program should display:
$$$$$$$$$$$ $$$$$ $$$$$ $$$$ $$$$ $$$ $$$
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
