Assignment4.java - Name Erica Phomsavanh Title...

Info icon This preview shows pages 1–3. Sign up to view the full content.

//*********************************************************** // Name: Erica Phomsavanh // Title: Assignment4.java // Author: Erica Phomsavanh // Description: Generate a multiplication table and display a pattern of stars based on input // Time spent: 6 hours // Date: 9/29/16 //********************************************************** /* Part 1: Writing Exercises a) The 3 required expressions for a for-loop are initialization, the condition, and the increment b) The corrected code is: int count = 1 while (count <= 10) { System.out.println("count: " + count): count++ } c)The output of the given code is: i is : 1 i is : 2 i is : 3 i is : 4 i is : 5 */ import java.util.Scanner; public class Assignment4 { public static void main(String[] args) { Scanner in = new Scanner(System.in); String answer; //declare for do loop //start do loop for continue do{ System.out.println("1. Generate a multiplication table"); System.out.println("2. Display a pattern of stars and character 'o'"); System.out.println("Your choice: "); int choice = in.nextInt(); //start switch statement for 2 choices switch (choice) { case 1: int tableSize; int num; //ask for input System.out.println("Please enter a number and table size: "); tableSize = in.nextInt(); num = in.nextInt(); if (tableSize < 0) { System.out.println("Please enter a number and table
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.
  • Spring '14
  • Networking, Natural number, Control table, System.out.println, int count, 6 hours, Erica Phomsavanh

{[ 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