Although many bugs, fortunately can run! Meet Up!
Package Javasecondweek;
Import Java.util.Scanner;
public class Polygongraph {
public static void Main (string[] args) {
Scanner scan = new Scanner (system.in);
String administer = "Younger";
String password = "Young123";
for (int a = 0; a < 3; a++) {
System.out.print ("Please enter user name:");
String userName = Scan.nextline ();
System.out.print ("Please enter password:");
String psd = Scan.nextline ();
if (username.equals (administer) &&psd.equals (password)) {
System.out.println ("Landing success");
System.out.println ();
for (int b = 0; b < 3; b++) {
SYSTEM.OUT.PRINTLN ("Input 1 Make square");
SYSTEM.OUT.PRINTLN ("Input 2 make inverted right triangle");
SYSTEM.OUT.PRINTLN ("Input 3 make positive right triangle");
SYSTEM.OUT.PRINTLN ("Input 4 make isosceles triangle");
SYSTEM.OUT.PRINTLN ("Input 5 make inverted isosceles triangle");
SYSTEM.OUT.PRINTLN ("Input 6 make diamond");
SYSTEM.OUT.PRINTLN ("Input 7 make Hollow Square");
SYSTEM.OUT.PRINTLN ("Input 0 exit");
System.out.print ("Please enter the corresponding number:");
int input = Scan.nextint ();
if (input = = 0) {
Break
}else{
switch (input) {
Case 1:{
for (int i = 0; i < 4; i++) {//Square
for (int j = 0; J < 4; J + +) {
System.out.print ("*" + "");
}
System.out.println ();
}
Break
}case 2:{
for (int i = 4; i > 0; i--) {//Inverted Right triangle
for (int j = 0; J < i; J + +) {
System.out.print ("*" + "");
}
System.out.println ();
}
Break
}case 3:{
for (int i = 0; I <= 4; i++) {//Positive right triangle
for (int j = 0; J < i; J + +) {
System.out.print ("*" + "");
}
System.out.println ();
}
Break
}case 4:{
for (int i = 0; i < 4; i++) {//positive isosceles triangle 13579
for (int j = 3; j > i; j--) {
System.out.print ("");
}
for (int j2 = 0; J2 < 2*i+1; j2++) {
System.out.print ("*");
}
System.out.println ();
}
Break
}case 5:{//Inverted isosceles triangle
for (int i = 4; i > 0; i--) {
for (int j = 3; j > i-1; j--) {
System.out.print ("");
}
for (int j = 0; J < 2*i-1; J + +) {
System.out.print ("*");
}
System.out.println ();
}
Break
}case 6:{
for (int i = 0; i < 3; i++) {//Diamond 13531
for (int j = 2; j > i; j--) {
System.out.print ("");
}
for (int j2 = 0; J2 < 2*i+1; j2++) {
System.out.print ("*");
}
System.out.println ();
}
for (int i = 2; i > 0; i--) {
for (int j = 2; j > i-1; j--) {
System.out.print ("");
}
for (int j = 0; J < 2*i-1; J + +) {
System.out.print ("*");
}
System.out.println ();
}
Break
}case 7:{//Hollow Square
System.out.print ("Please enter the side length of the square:");
int n = scan.nextint ();
for (int i = 0; i < n; i++) {
System.out.print ("*");
}
System.out.println ();
for (int j = 0; J < N-2; J + +) {
System.out.print ("*");
for (int i = 0; i < n-2; i++) {
System.out.print ("");
}
System.out.println ("*");
}
for (int i = 0; i < n; i++) {
System.out.print ("*");
}
Break
}default:{
SYSTEM.OUT.PRINTLN ("Input error, please re-enter");
System.out.println ();
Continue
}
}
}
Break
}
}else{
System.out.println ("Incorrect account or password, please re-enter");
Continue
}
Break
}
}
}
A busy day, the first time to write more than 100 lines of code