This is java, I am getting an error message. Below is the code i have so far and also the error that is coming up import

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

This is java, I am getting an error message. Below is the code i have so far and also the error that is coming up import

Post by answerhappygod »

This is java, I am getting an error message. Below is the code ihave so far and also the error that is coming up
import java.util.Scanner;
public class DrawRightTriangle { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); char triangleChar; int triangleHeight; System.out.println("Enter acharacter:"); triangleChar = scnr.next().charAt(0); for(int i=0;i<triangleHeight;i++) { for(int j =0;j<=i;j++) { System.out.print(triangleChar +" "); } System.out.println(); } }} ERROR DrawRightTriangle.java:12: error: variable triangleHeight might nothave been initialized for(int i=0;i<triangleHeight;i++ ) ^ 1error
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply