CSC 190 Lecture 25: code

20 views3 pages

Document Summary

* purpose: this program will take a numerical input from 1 to 13. * and print a number triangle with x amount of lines, where x is the number that. * was input by the user import java. util. scanner; public class numbertriangle { public static void triangle1(int n) { System. out. println("please enter a value greater than or equal return; int val = 1; for (int i = 1; i <= n; i++) { for (int j = 1; j <= i; j++) { System. out. println(); public static void triangle2(int n) { to 1. " System. out. println("please enter a value greater than or equal return; int val2, val1 = 1, m; for (int i = 1; i <= n; i++) { System. out. printf("%3d", val1); val2 = val1; m = 1; for (int j = 1; j < i; j++) { val2 = val2 + (n - m); System. out. println(); val1++; public static void triangle3(int n) { to 1. "

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents

Related Questions