JAVA program to print Downward Triangle Star Pattern
Code :
package com.company;
import java.util.Scanner;
public class StarPattern3 {
public static void main(String[] args) {
// takes the input from user
Scanner sc = new Scanner(System.in);
System.out.println("Enter a number :");
int n = sc.nextInt();
//int n = 5;
for(int i=1; i<=n; i++) {
for(int j=i; j<=n; j++) {
System.out.print("* ");
}
System.out.println();// goes to next line
}
}
}
"C:\Program Files\Amazon Corretto\jdk1.8.0_282\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.3.3\lib\idea_rt.jar=61465:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.3.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Amazon Corretto\jdk1.8.0_282\jre\lib\charsets.jar;C:\Program Files\Amazon Corretto\jdk1.8.0_282\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Amazon Corretto\jdk1.8.0_282\jre\lib\ext\cldrdata.jar;C:\Program Files\Amazon Corretto\jdk1.8.0_282\jre\lib\ext\dnsns.jar;C:\Program Files\Amazon Corretto\jdk1.8.0_282\jre\lib\ext\jaccess.jar;C:\Program Files\Amazon Corretto\jdk1.8.0_282\jre\lib\ext\jfxrt.jar;C:\Program Files\Amazon Corretto\jdk1.8.0_282\jre\lib\ext\localedata.jar;C:\Program Files\Amazon Corretto\jdk1.8.0_282\jre\lib\ext\nashorn.jar;C:\Program Files\Amazon Corretto\jdk1.8.0_282\jre\lib\ext\sunec.jar;C:\Program Files\Amazon Corretto\jdk1.8.0_282\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Amazon Corretto\jdk1.8.0_282\jre\lib\ext\sunmscapi.jar;C:\Program Files\Amazon Corretto\jdk1.8.0_282\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Amazon Corretto\jdk1.8.0_282\jre\lib\ext\zipfs.jar;C:\Program Files\Amazon Corretto\jdk1.8.0_282\jre\lib\jce.jar;C:\Program Files\Amazon Corretto\jdk1.8.0_282\jre\lib\jfr.jar;C:\Program Files\Amazon Corretto\jdk1.8.0_282\jre\lib\jfxswt.jar;C:\Program Files\Amazon Corretto\jdk1.8.0_282\jre\lib\jsse.jar;C:\Program Files\Amazon Corretto\jdk1.8.0_282\jre\lib\management-agent.jar;C:\Program Files\Amazon Corretto\jdk1.8.0_282\jre\lib\resources.jar;C:\Program Files\Amazon Corretto\jdk1.8.0_282\jre\lib\rt.jar;C:\Users\PRIYA\IdeaProjects\sample\out\production\sample" com.company.StarPattern3 Enter a number : 5 * * * * * * * * * * * * * * * Process finished with exit code 0
Comments
Post a Comment