Write a method called printstars which will accept an

This preview shows page 12 - 16 out of 16 pages.

surrounded by a box of stars (asterisks), as shown by the following screenshot. Write a method called printStars() which will accept an integer number as a parameter. The method should print out a row of stars with the length of the row equal to the parameter. The main() method of your application should use the printStars() method to print the top and bottom of the box. import java.io.*; public class Q6{ public static void main(String[] args){ System.out.print("Enter a String: "); String input = readInput(); //COMPLETE THE MAIN METHOD HERE }//end of the main method //Assume the readInput method is declared here private static String readInput(){ ... }
Image of page 12

Subscribe to view the full document.

Question/Answer Sheet - Page 13 - CompSci 101 S1 C SURNAME: ...................................................... FORENAMES: ........................................................... CONTINUED //WRITE THE PRINTSTARS METHOD HERE private static ______ printStars(_______________________){ }//End of the printStars method }//End of the application (15 marks)
Image of page 13
Question/Answer Sheet - Page 14 - CompSci 101 S1 C SURNAME: ...................................................... FORENAMES: ........................................................... CONTINUED Question 7 (10 marks) Examine the application below: public class Q7 { public static void main(String[] args) { int[] values = new int[10]; for (int i = 0; i < values.length; i++) { values[i] = i%3; } int count = 0; for (int i = 0; i < values.length; i++) { if (values[i] == 0) count++; } System.out.println(count); } } What is the output of the above application? C:\> java Q7 (10 marks)
Image of page 14

Subscribe to view the full document.

Question/Answer Sheet - Page 15 - CompSci 101 S1 C SURNAME: ...................................................... FORENAMES: ........................................................... Question 8 (10 marks) Given the following paint() method: public void paint(Graphics g) { g.drawLine(50, 50, 50, 150); g.drawLine(150, 50, 50, 100); } Accurately draw what would appear in the Frame below for which the paint() method above is defined. The window below is 200 pixels wide and 200 pixels high. (10 marks)
Image of page 15
Question/Answer Sheet - Page 16 - CompSci 101 S1 C SURNAME: ...................................................... FORENAMES: ........................................................... OVERFLOW PAGE (If you have used this page, please indicate clearly under the relevant question that you have overflowed to this page)
Image of page 16
You've reached the end of this preview.
  • Summer '12
  • AdrianaFerraro
  • Computer Science, English-language films, ........., Black-and-white films, Given name

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern