[text] Assignment 3

Viewer

copydownloadembedprintName: Assignment 3
  1. /// Samhitha Balaji
  2. /// 09/17/21
  3. /// Assignment 3. Draw a Pretty Picture
  4.  
  5. //This program will use ASCII characters to create an abstract design
  6.  
  7. public class assign03 {
  8.         // Sets variables for image - size can be varied
  9.         public static int SIZE = 10;
  10.         public static int DOUBLE = 2;
  11.        
  12.         //Method creates the point/triangle of image 
  13.         public static void top() {
  14.                 for (int i = 0; i <= SIZE; i++) { //Loop to match size declared by variable
  15.                         for (int j = 1; j <= (-1 * i + SIZE); j++) { 
  16.                                 System.out.print("  ");
  17.                         }      
  18.                         System.out.print(" _/");
  19.                         for (int k = 1; k <= (i * DOUBLE); k++) {
  20.                                 System.out.print("  ");
  21.                         }      
  22.                         System.out.print("\\_");
  23.                         System.out.println("");
  24.        
  25.                 }
  26.                
  27.         }
  28.        
  29.         //Method creates upward facing line of image
  30.         public static void lineUp() {
  31.                 System.out.println();
  32.                 for (int m = 1; m <= DOUBLE; m++) {
  33.                         for (int x = 1; x <= (SIZE); x++) {
  34.                                 System.out.print("/");
  35.                                 System.out.print("\\");
  36.                         }
  37.                         System.out.print(" ");
  38.                 }
  39.                 System.out.println("");
  40.                
  41.         }
  42.        
  43.         //Method creates straight lines of image
  44.         public static void lineReg() {
  45.                 for (int k = 1; k <= DOUBLE; k++) { //Loop that prints lines twice
  46.                         for (int y = 1; y <= DOUBLE; y++) { //Loop that repeats line with space
  47.                                 for (int x = 1; x <= (SIZE*DOUBLE); x++) { //Determines line size based on SIZE
  48.                                         System.out.print("_");
  49.                                 }
  50.                                 System.out.print(" ");
  51.                         }
  52.                         System.out.println();
  53.                 }              
  54.                        
  55.         }
  56.        
  57.         //Method creates downward facing line of image
  58.         public static void lineDown() {
  59.                 System.out.println();
  60.                 for (int m = 1; m <= DOUBLE; m++) {
  61.                         for (int x = 1; x <= (SIZE); x++) {
  62.                                 System.out.print("\\");
  63.                                 System.out.print("/");
  64.                         }
  65.                         System.out.print(" ");
  66.                 }
  67.                
  68.                 System.out.println();
  69.                
  70.         }
  71.        
  72.  
  73.         public static void main(String[] args) {
  74.                 top();
  75.                 lineUp();
  76.                 lineReg();
  77.                 lineDown();
  78.        
  79.  
  80.         }
  81.  
  82. }

Editor

You can edit this paste and save as new:


File Description
  • Assignment 3
  • Paste Code
  • 18 Sep-2021
  • 1.85 Kb
You can Share it: