Question: This program reads in two numbers C and R from the user, and displays a figure with R-rows and (2*C-1)-columns of $ characters as the
This program reads in two numbers C and R from the user, and displays a figure with R-rows and (2*C-1)-columns of "$" characters as the following pattern. Note that it is not simple 2*C columns! For instance, if the user enters a 3 for R and 5 for C, it should display: 
Solving for the ?
Scanner kb = new Scanner(System.in); System.out.println("Enter row:"); int R = kb.nextInt(); System.out.println("Enter column:"); int C = kb.nextInt(); if(R>C) R=C; for(int i = 0; i; i++) // Q1 # of $ in the first line System.out.print("$"); System.out.println(); // top line for(int i = 0; i; i++){ // 02, how many lines after top line displayed? for(int j = 0; j; j++){ // 03, how many $s in the left part System.out.print("$"); } for(int j = 0; j; j++){ // Q4, how many spaces in the middle? System.out.print(" "); } for(int j = 0; j; j++){ // Q5, repeat the same in Q3! System.out.print("$"); } System.out.println(); } $$$$$$$$$ $$$$ $$$$ $$$ $$$
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
