Write some Java code involving if, else if, and else statements that are equivalent to the following switch case: switch(number) { case 2:     System.out.println("Second place"); case 1:     System.out.println("First place");     System.out.println("Top 2 finish!");     break; case 3:     System.out.println("Third place");     break; default:     System.out.println("Also ran"); }

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 20RQ
icon
Related questions
Question

JAVA Question

  1. Override the equals method for the JediMaster class. The JediMaster class has two fields that should be considered when testing for equality: one of type String with the identifier name, and the other of type int with the identifier midichlorianCount.
  2. Write a draw method for the Ball class that will allow a Ball object to draw itself. You may assume the class has the following instance variables: xPos, yPos, diameter, color. The first three are of type int, and the last is of type Color.
  3. Suppose you are writing a GUI application and have created a subclass of the JFrame class that contains a JTextField object with the identifier numberOfDonuts. Write some Java code that will allow you to get the value a user has entered in that field and convert it to an int. You do not need to worry about checking if the value is a number first.
  4. Write a mutator method for an instance variable of type int with the identifier employeeID. Your mutator method should not allow values larger 9999 or less than 0 and automatically adjust values outside of that range to the appropriate max or minimum value.
  5. Write a unit test (both method header and body) for a static method of the Conversion class called feetToInches. The method takes a single argument of type int which represents for the number of feet to be converted. You can assume that there are 12 inches in 1 foot.
  6. Write some Java code that will generate random numbers 1 – 10 inclusive until it generates the number 10. Your code should also keep a count of how many numbers have been generated. You can assume that a Random object with the identifier rand has already been declared and instantiated for you to use in your solution.

 

  1. Write some Java code involving if, else if, and else statements that are equivalent to the following switch case:
    switch(number) {
    case 2:
        System.out.println("Second place");
    case 1:
        System.out.println("First place");
        System.out.println("Top 2 finish!");
        break;
    case 3:
        System.out.println("Third place");
        break;
    default:
        System.out.println("Also ran");
    }
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 7 steps with 10 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,