EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
bartleby

Videos

Question
Book Icon
Chapter 5, Problem 4GZ
Program Plan Intro

Dice game

Program plan:

  • In a file “Die.java”, create a class “Die”,
    • Declare and initialize the necessary variables.
    • Define the constructor “Die()”to compute the value in terms of random number.
    • Define the method “get_Value()” to return the value.
  • In a file “TwoDice2.java”, create a class “TwoDice2”,
    • Define the method “main ()”,
      • Create two objects for “Die” class.
      • Assign the first die value returned from the “get_Value()” method.
      • Assign the second die value returned from the “get_Value()” method.
      • Print two die values.
      • Check whether the first die value is greater than the second die value,
        • If it is true, print the message as “First die value is greater”.
      • Otherwise, check whether the second die value is greater than the first die value,
        • If it is true, print “Second die value is greater”.
      • Otherwise, print “The dice are equal”.

Blurred answer
Students have asked these similar questions
Carly’s Catering provides meals for parties and special events. In previous chapters, you have developed a class that holds catering event information and an application that tests the methods using four objects of the class. Now modify the Event and EventDemo classes as follows: Modify the method that sets the event number in the Event class so that if the argument passed to the method is not a four-character String that starts with a letter followed by three digits, then the event number is forced to A000. If the initial letter in the event number is not uppercase, force it to be so. Add a contact phone number field to the Event class. Add a set method for the contact phone number field in the Event class. Whether the user enters all digits or any combination of digits, spaces, dashes, dots, or parentheses for a phone number, store it as all digits. For example, if the user enters (920) 872-9182, store the phone number as 9208729182. If the user enters a number with fewer or more…
This is the question I am stuck on - Radio station KJAVA wants a class to keep track of recordings it plays. Create a class named Recording that contains fields to hold methods for setting and getting a Recording’s title, artist, and playing time in seconds. Write an application that instantiates five Recording objects and prompts the user for values for the data fields. Then prompt the user to enter which field the Recordings should be sorted by—(S)ong title, (A)rtist, or playing (T)ime. Perform the requested sort procedure, and display the Recording objects. This is what I have so far - public class Recording {     private String song;     private String artist;     private int playTime;     public void setSong(String title) {         this.song = title;     }     public void setArtist(String name) {         this.artist = name;     }     public void setPlayTime(int time) {         this.playTime = time;     }     public String getSong() {         return song;     }     public String…
I need help with this. Thanks in advance. Write an application that accepts a word from a user and converts it to Pig Latin. If a word starts with a consonant, the Pig Latin version removes all consonants from the beginning of the word and places them at the end, followed by ay. For example, cricket becomes icketcray. If a word starts with a vowel, the Pig Latin version is the original word with ay added to the end. For example, apple becomes appleay. If y is the first letter in a word, it is treated as a consonant; otherwise, it is treated as a vowel. For example, young becomes oungyay, but system becomes ystemsay. For this program, assume that the user will enter only a single word consisting of all lowercase letters. import java.util.*;public class PigLatin {public static void main(String[] args) {// Write your code here}public static boolean isVowel(char c) {// Write your code here}}
Knowledge Booster
Background pattern image
Computer Science
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
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
CPP Function Parameters | Returning Values from Functions | C++ Video Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=WqukJuBnLQU;License: Standard YouTube License, CC-BY