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"); }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education