Question
In the second part of the assignment, you are going to generate output that looks like the following:
View Answer
Try AI Generated Solution
Answer

/**! ******************************************************************************** * name - {###########} * date - 2022-10-12 * brief - DrawRocket class contains methods that print different ascii patterns * such as ring, cone and triangles. * * the functions implemented in the file is idiolized by the * AP Computer Science Project 2 – Rocket Ship Doc File. ******************************************************************************** */ public class DrawRocket { /** * This is a helper method to reduce redundancy in the functions in this class. * name repeatStore means store a repeating value in a variable. * @param value - the value that repeats int the line * @param len - length of repetition of the value * @return String which is value*len. */ public static String repeatStore( String value, int len){ String store = ""; /**variable to store the final repeating value. */ /**this loop adds the repeating value to the store variable len times. */ for(int j = 1; j<= len ; j++){ store+=value; } return store; } /** ******************************* * First Part Starts Here ******************************** */ /** this function prints a custom(hardcoded) Ascii Drawing. * printing a pyramid with help of (*) * the height of the pyramid is size (created locally for this part inside the method) * at ith line number of stars = (2*i - 1) */ public static void asciiDrawing(){ int size = 12; //this size variable decides the height of the pyramid. /** * line - String to store and print ith line of the cone * spaces - holds the number of spaces appearing before the cone stars printing. * stars - stores the (*) x (i-1) stars for the ith line of the pyramid; */ String line = "", spaces = "", stars = ""; for(int i = 1; i<= size; i++){ /**get the size-i wide space in spaces variable. */ spaces = repeatStore(" ", size-i); /**get the (*) x (i-1) stars in stars variable variable. */ stars = repeatStore("*", i-1); /** adding the initial spaces to the line */ line = spaces; /** since stars variable holds i-1 stars so below line adds (2*i-1) require stars in ith line*/ line+=stars+"*"+stars; /**print the ith line to the console. */ System.out.println(line); } } /** ******************************* * Second Part Starts Here ******************************* */ /** * The size of the Rocket as described in the doc. * Change the SIZE value here to produce rocket of different sizes * keep SIZE >= 1 ; */ private static final int SIZE = 3; /** * This method prints the cone structured ascii art. * The height of the cone (number of lines in the cone) will be 2*SIZE-1 * @return Nothing */ public static void cone(){ int n = 2*SIZE ; /** * line - String to store and print ith line of the cone * spaces - holds the number of spaces appearing before the cone starts printing. * fs - Forward Slash (fs) : i number of forward slash in ith line to print on console * bs - Backward Slash (bs) : i number of backward slash in the ith line to print on the console. */ String spaces = "", fs ="",bs="", line = ""; for(int i =1;i <= n-1; i++){ /**get the n-i wide space in spaces variable. */ spaces = repeatStore(" ", n-i); /**get the (/) x (i) forward slash in fs variable. */ fs = repeatStore( "/", i); /**get the (\) x (i) backward slash in fs variable. */ bs = repeatStore("\\", i); /** adding the initial spaces to the line */ line = spaces; /** putting all the charactes in the sequence in the ith line. */ line+= fs+"**"+bs; /**print the ith line to the console. */ System.out.println(line); } } /** * Ring function prints an single line ascii pattern using +, = , and * * Size of the ring = 2* SIZE * number of stars in the ring will always be even * @return Nothing */ public static void ring(){ /** in the ring (=+) appears 2*SIZS times hence adding the (=*) in the line */ String line = repeatStore("=*", 2*SIZE); /** adding the + character at the begining and the end of the line printing it to the console. */ System.out.println("+"+line+"+"); } /** * TriangleUP function prints two verticle triaglular shaped ascii art with dot(.) filled in the blank spaces * Characters used = (., / ,\ , and |) * @return Nothing */ public static void triangleUp(){ /** * line - String to store and print ith line of the cone * dots - holds the dots appearing in one side of traingle on ith line. * traingles - holds the number of triangles(/\) appearing in ith line of the pattern */ String line , traingles, dots =""; for(int i = 1; i<= SIZE;i++){ /**get the (.) x (SIZE - i) dots in dots variable. */ dots = repeatStore(".",SIZE - i); /**get the (/\) x (i) traingles in traingles variable. */ traingles = repeatStore("/\\",i); /** putting all the charactes in the sequence in the ith line. */ line =dots + traingles + dots; line+=line; /**this lines adds the symmetric traingle side ways to the current one */ /**print the ith line to the console. */ System.out.println("|"+line+"|"); } } /** * This function prints the vertical mirror image (inverted down triagle) * of the triangleUp function * @return Nothing */ public static void triangleDown(){ /** the local variables here signify the same meaning as in function triangleUp */ String line , triangles, dots =""; for(int i = 1; i<= SIZE;i++){ /**get the (.) x (i - 1) dots in dots variable. */ dots = repeatStore(".", i-1); /**get the (\/) x (SIZE-i+1) traingles in traingles variable. */ triangles = repeatStore("\\/", SIZE-i+1); /** putting all the charactes in the sequence in the ith line. */ line = dots + triangles + dots; line+=line; /**this lines adds the symmetric traingle side ways to the current one */ /**print the ith line to the console. */ System.out.println("|"+line+"|"); } } /** * This is the main method * which makes use of cone, ring, triangleUp and triangleDonw functions to print the rocket. * this function also calls the asciiDrawing function to print a custom ascii drawing of a doll. * @param args Unused. * @return Nothing. */ public static void main(String[] args){ /**First Part - Printing a custom ascii drawing which is being called */ asciiDrawing(); System.out.println(); /**Second Part - printing the rocket drawing */ cone(); ring(); triangleUp(); triangleDown(); ring(); triangleDown(); triangleUp(); ring(); cone(); } }

In the second part of the assignment, you are going to generate output that looks like the following:

Get solved by expert tutor

Not the answer you're looking for? Let our experts create a unique solution for you

Found 10 similar results for your question:

Ques 6 Your goal is to navigate a robot out of a maze. The robot starts in the center of the maze facing north. You can turn the robot to face north, east, south, or west. You can direct the robot to move forward a certain distance although it will stop after hitting a wall. a) Formulate this problem. This means you will have to describe initial state, goal test,successor function. and cost function. Successor function is a description of the robots successive actions after the initial state. We’ll define the coordinate system so that the center of the maze is at (0, 0), and the maze itself is a square from (-1,–1) to (1, 1)

5. (P31,In modern packet-switched networks, including the Internet, the source host segments long, application layer messages (for example, an image or a music file) into smaller packets and sends the packets into the network. The receiver then reassembles the packets back into the original message. We refer to this process as message segmentation. The figure below illustrates the end-to-end transport of a message with and without message segmentation. Consider a message that is 8 * 106 bits long that is to be sent from source to destination in the figure. Suppose each link in the figure is 2 Mbps. Ignore propagation, queuing, and processing delays. (a) Consider sending the message from source to destination without message segmentation. How long does it take to move the message from the source host to the first packet switch? Keeping in mind that each switch uses store-and-forward packet switching, what is the total time to move the message from source host to destination host? Now suppose that the message is segmented into 800 packets, with each packet being 10,000 bits long. How long does it take to move the first packet from source host to the first switch? When the first packet is being sent from the first switch to the second switch, the second packet is being sent from the source host to the first switch. At what time will the second packet be fully received at the first switch? c) How long does it take to move the file from source host to destination host when message segmentation is used? Compare this result with your answer in part (a) and comment. ) In addition to reducing delay, what are reasons to use message segmentation? e) Discuss the drawbacks of message segmentation. In addition to reducing delay, what are reasons to use message segmentation? -Discuss the drawbacks of message segmentation.

. [10 points]Suppose a process in the Host C has a UDP socket with port number 6789. Suppose both Host A and Host B each send a UDP segment to Host C with destination port number 6789. Will both of these segments be directed to the same socket at Host C? If so, how will the process at Host C know that these two segments originated from two different hosts?

A particular system is controlled by an operator through commands entered from a keyboard.The average number of commands entered in an 8-hour interval is 60. Show your work toreceive full credit. a. Suppose the CPU scans the keyboard every 100ms. How many times will the keyboard bechecked in an 8-hour period? b. By what fraction would the number of CPU visits to the keyboard be reduced if interrupt-driven 1/0 were used?

22. Many CPU-scheduling algorithms are parameterized. For example, the RR algorithm requires a parameter to indicate the time slice. Multilevel feedback queues require parameters to define the number of queues, the scheduling algorithms for each queue, the criteria used to move processes between queues, and so on. These algorithms are thus really sets of algorithms (for example, the set of RR algorithms for all time slices, and so on). One set of algorithms may include another (for example, the FCFS algorithm is the RR algorithm with an infinite time quantum). What (if any) relation holds between the following pairs of algorithm sets? a. Priority and SJF b. Multilevel feedback queues and FCFS c. Priority and FCFS

23. Suppose that a CPU scheduling algorithm favors those processes that have used the least processor time in the recent past. Why will this algorithm favor I/O-bound programs and yet notpermanently starve CPU-bound programs?

1) In a computer instruction format, the instruction length is 11 bits and the size of an address field is 4 bits. Is it possible to have: 5 two-address instructions 45 one-address instructions 32 zero-address instructions using the specified format? Justify your answer. b) Assume that a computer architect has already designed 6 two-address and 24 zero address instructions using the instruction format above. What is the maximum number of one-address instructions that can be added to the instruction set?

(1) In a computer system, memory operations currently take up 30% of execution time. A new gadget called a cache (i.e. an L1 cache) speeds-up 80% of the memory operations by a factor of 4. What is the speed-up due to the cache? ) [5] A second new gadget called an L2 cache speeds-up half the remaining20% of the memory operations by a factor of 2. What is the total speed-up with the L1 and L2 cache together?

client, and there is no other traffic on this path. Assume each packet of size L bits, and both links have the samepropagation delay dprop- (a) What is the packet inter-arrival time at the destination? That is, how much time elapses from when the lastbit of the first packet arrives until the last bit of the second packet arrives? (b) Now assume that the second link is the bottleneck link (i.e., RcjRs). Is it possible that the second packetqueues at the input queue of the second link? Explain. Now suppose that the server sends the second packetT seconds after sending the first packet. How large must T be to ensure no queuing before the second link?Explain. Consider the figure (a) below. Assume that we know the bottleneck link along the path from the server to theclient is the first link with rate Rs bits/sec. Suppose we send a pair of packets back to back from the server to the

Let a denote the rate of packets arriving at a link in packets/sec, and let µ denote the links transmission rate in packets/sec. Based on the formula for the total delay (i.e., the queuing delay plus the transmission delay) derived in the previous problem, derive a formula for the total delay in terms of a and µ. Note that the link's transmission rate in packet/sec is R/L.