*
*
**
*
**
***
*
**
***
****
*
**
***
****
*****
---------- Post added at 03:36 PM ---------- Previous post was at 03:31 PM ----------
Here is the code for the three other drawings.
For some reason the indents get removed when I come from IDE
[FONT=Courier New] [/FONT][FONT=Courier New][COLOR=#941edf][FONT=Courier New][COLOR=#941edf]import[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] java.util.Scanner;
[/FONT][FONT=Courier New][COLOR=#941edf][FONT=Courier New][COLOR=#941edf]public[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] [/FONT][FONT=Courier New][COLOR=#941edf][FONT=Courier New][COLOR=#941edf]class[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] Lab06
{
[/FONT][FONT=Courier New][COLOR=#941edf][FONT=Courier New][COLOR=#941edf]public[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] [/FONT][FONT=Courier New][COLOR=#941edf][FONT=Courier New][COLOR=#941edf]static[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] [/FONT][FONT=Courier New][COLOR=#941edf][FONT=Courier New][COLOR=#941edf]void[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] main(String[] args)
{
[/FONT][FONT=Courier New][COLOR=#fa6400][FONT=Courier New][COLOR=#fa6400]// Variables
[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New][/FONT][FONT=Courier New][COLOR=#941edf][FONT=Courier New][COLOR=#941edf]int[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] x;
[/FONT][FONT=Courier New][COLOR=#941edf][FONT=Courier New][COLOR=#941edf]int[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] row_count;
[/FONT][FONT=Courier New][COLOR=#941edf][FONT=Courier New][COLOR=#941edf]int[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] col_count;
[/FONT][FONT=Courier New][COLOR=#941edf][FONT=Courier New][COLOR=#941edf]int[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] tri_count;
Scanner keyboard = [/FONT][FONT=Courier New][COLOR=#941edf][FONT=Courier New][COLOR=#941edf]new[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] Scanner(System.in);
[/FONT][FONT=Courier New][COLOR=#fa6400][FONT=Courier New][COLOR=#fa6400]// Line of asterisks
[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]System.out.print([/FONT][FONT=Courier New][COLOR=#00cb00][FONT=Courier New][COLOR=#00cb00]"Enter an integer greater than 0 for length of line: "[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]);
x = keyboard.nextInt();
System.out.println([/FONT][FONT=Courier New][COLOR=#00cb00][FONT=Courier New][COLOR=#00cb00]"Line of "[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] + x + [/FONT][FONT=Courier New][COLOR=#00cb00][FONT=Courier New][COLOR=#00cb00]" asterisks"[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]);
[/FONT][FONT=Courier New][COLOR=#941edf][FONT=Courier New][COLOR=#941edf]while[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] (0 < x)
{
System.out.print([/FONT][FONT=Courier New][COLOR=#00cb00][FONT=Courier New][COLOR=#00cb00]"*"[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]);
x--;
}
System.out.println([/FONT][FONT=Courier New][COLOR=#00cb00][FONT=Courier New][COLOR=#00cb00]"\n"[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]);
[/FONT][FONT=Courier New][COLOR=#fa6400][FONT=Courier New][COLOR=#fa6400]// Square block of asterisk
[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]System.out.print([/FONT][FONT=Courier New][COLOR=#00cb00][FONT=Courier New][COLOR=#00cb00]"Enter an integer greater than 0 for size of square: "[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]);
x = keyboard.nextInt();
row_count = x;
col_count = x;
System.out.println(x + [/FONT][FONT=Courier New][COLOR=#00cb00][FONT=Courier New][COLOR=#00cb00]" by "[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] + x + [/FONT][FONT=Courier New][COLOR=#00cb00][FONT=Courier New][COLOR=#00cb00]" square of asterisks"[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]);
[/FONT][FONT=Courier New][COLOR=#941edf][FONT=Courier New][COLOR=#941edf]while[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] (0 < col_count)
{
row_count = x;
[/FONT][FONT=Courier New][COLOR=#941edf][FONT=Courier New][COLOR=#941edf]while[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] (0 < row_count)
{
System.out.print([/FONT][FONT=Courier New][COLOR=#00cb00][FONT=Courier New][COLOR=#00cb00]"*"[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]);
row_count--;
}
System.out.println();
col_count--;
}
System.out.println([/FONT][FONT=Courier New][COLOR=#00cb00][FONT=Courier New][COLOR=#00cb00]"\n"[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]);
[/FONT][FONT=Courier New][COLOR=#fa6400][FONT=Courier New][COLOR=#fa6400]// Upside-down right triangle
[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]System.out.print([/FONT][FONT=Courier New][COLOR=#00cb00][FONT=Courier New][COLOR=#00cb00]"Enter an integer greater than 0 for size of upside-down right triangle: "[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]);
x = keyboard.nextInt();
row_count = x;
col_count = x;
System.out.println([/FONT][FONT=Courier New][COLOR=#00cb00][FONT=Courier New][COLOR=#00cb00]"Base of upside-down right triangle is "[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] + x);
[/FONT][FONT=Courier New][COLOR=#941edf][FONT=Courier New][COLOR=#941edf]while[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] (0 < col_count)
{
row_count = col_count;
[/FONT][FONT=Courier New][COLOR=#941edf][FONT=Courier New][COLOR=#941edf]while[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] (0 < row_count)
{
System.out.print([/FONT][FONT=Courier New][COLOR=#00cb00][FONT=Courier New][COLOR=#00cb00]"*"[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]);
row_count--;
}
System.out.println();
col_count--;
}
[/FONT][FONT=Courier New][COLOR=#fa6400][FONT=Courier New][COLOR=#fa6400]// Number of right triangles
[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]System.out.print([/FONT][FONT=Courier New][COLOR=#00cb00][FONT=Courier New][COLOR=#00cb00]"Enter an integer greater than 0 for the number of triangles (w/ increasing base size): "[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]);
x = keyboard.nextInt();
tri_count = x;
System.out.println([/FONT][FONT=Courier New][COLOR=#00cb00][FONT=Courier New][COLOR=#00cb00]"Number of triangles (w/ increasing base size) is "[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] + x);
}
}
[/FONT]


Sign In
Create Account


Back to top









