105k views
0 votes
Extra Credit: The Linc (parking lot and stadium)In celebration of the upcoming Super Bowl, for a maximum 10 points of extra credit, you may try to reproduce the ASCII Art shown below of Lincoln Stadium, home of the Philadelphia Eagles. You should still include a class constant for the SIZE; in Dr. Yates' implementation, the SIZE value that produces the picture below is 4, and works for any size >= 2. You must include loops and nested loops to make this work correctly; you CANNOT simply include a separate println statement for each line of the drawing. You will get the full extra credit points only if you duplicate the drawing EXACTLY. (Note: this is a fairly tricky figure to do right.) The parking lot alone is worth a maximum of 2 points.

User Noah Clark
by
5.5k points

1 Answer

3 votes

Answer:

Step-by-step explanation:

// Below is the code to draw parking lot only , i have also put the o/p of code.

import java.util.*;

import java.lang.*;

import java.io.*;

public class Linc

{

static int size=4;

static int numBoxes = 1; // one row.

static int height =(int) Math.pow(size, 2); //Just how many | will it have.

static int width = 2; // two boxes in a row

public static void main (String[] args) throws java.lang.Exception

{

top();

printHeight();

}

public static void top(){

for(int i = 0; i <= numBoxes*width;i++)

{

if(i%width == 0) {//When this happens we're in a new box.

System.out.print(" ");

System.out.print("____________");

}

else

System.out.print(" ");

}

System.out.println(); //Move to next line.

}

public static void printHeight(){

for(int j = 0; j < height;j++){

for(int i = 0; i <= numBoxes*width;i++)

{

if(i%width == 0) "); //Whenever this happens we're in a new box.

System.out.print("____________");

else

System.out.print(" ");

}

System.out.print("|");

System.out.println(); //Move to next line.

}

}

}

User Harry Sarshogh
by
5.1k points