Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Collier_NestedLoops
- {
- public static void main(String[] args)
- {
- KeyboardReader reader = new KeyboardReader();
- int Menu = 0;
- do
- {
- Menu = reader.readInt("What would you like to go to?(Enter 1-6, 7 to exit):\n");
- if(Menu==1)
- {
- for (int j=1; j<=8; j++)
- {
- System.out.print("\t" + j);
- }
- System.out.println();
- for (int i=1; i<=8; i++)
- {
- System.out.print(i + "\t");
- for (int j=1; j<=8; j++)
- {
- System.out.print(j*i + "\t");
- }
- System.out.println();
- }
- }
- if(Menu==2)
- {
- for (int c=1; c<=5; c++)
- {
- for (int b=1; b<=5; b++)
- {
- System.out.print("M");
- }
- System.out.println();
- }
- }
- if(Menu==3)
- {
- for (int z=5; z>=1; z--)
- {
- for (int x=1; x<=z; x++)
- {
- System.out.print("M");
- }
- System.out.println();
- }
- }
- if(Menu==4)
- {
- int j = 0;
- for (int g=5; g>=1; g--)
- {
- j++;
- int p;
- for (p=1; p<=j; p++)
- {
- System.out.print(" ");
- }
- for (int h=1; h<=g; h++)
- {
- System.out.print("M");
- }
- System.out.println();
- }
- }
- if(Menu==5)
- {
- for (int o=1; o<=5; o++)
- {
- for (int g=o; g<=4; g++)
- {
- System.out.print(" ");
- }
- for (int n=2; n<=(o*2); n++)
- {
- System.out.print("M");
- }
- System.out.println();
- }
- }
- if(Menu==6)
- {
- int Size = reader.readInt("Enter an Odd Diamond Size: ");
- int t = Size%2;
- while(t==0)
- {
- System.out.println("Invalid Entry");
- Size = reader.readInt("Enter an Odd Diamond Size: ");
- t = Size%2;
- }
- int Num = Size/2;
- int Start = 1;
- for(int i=1; i<=((Size/2)+1); i++)
- {
- for(int j=1; j<=Num; j++)
- {
- System.out.print(" ");
- }
- for(int o=1; o<=Start; o++)
- {
- System.out.print("*");
- }
- System.out.println();
- Num--;
- Start+=2;
- }
- Start-=4;
- Num=1;
- for(int h=1; h<=Size/2; h++)
- {
- for(int k=1; k<=Num; k++)
- {
- System.out.print(" ");
- }
- for(int c=1; c<=Start; c++)
- {
- System.out.print("*");
- }
- System.out.println();
- Start-=2;
- Num++;
- }
- }
- }while(Menu!=7);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement