Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Bartleby Related Questions Icon
Related questions
Question
JAVA code can only be added to the MessageDetails.java file. Between lines of get code (ie libnes 12 and 14, as seen on image).
Transcribed Image Text:**Overview of Java Code for Message Handling**
The provided Java code demonstrates how to utilize mutator and accessor methods within a class to manage simple message data. The `Message` class includes fields and methods to handle a greeting message and a corresponding area code.
**Class and Methods Description:**
1. **Class Definition:**
```java
public class Message {
```
The class is defined as `Message` and includes private fields for encapsulating data.
2. **Fields:**
```java
private String greeting;
private int areaCode;
```
- `greeting`: Stores the greeting message as a `String`.
- `areaCode`: Stores the area code as an `int`.
3. **Mutator Methods:**
- **setGreeting Method:**
```java
public void setGreeting(String inputGreeting) {
greeting = "Hi, you have reached " + inputGreeting;
}
```
This method sets the `greeting` field by appending the input string to a predefined message.
- **setAreaCode Method:**
```java
public void setAreaCode(int inputAreaCode) {
areaCode = inputAreaCode;
}
```
This method assigns the input integer to the `areaCode` field.
4. **Accessor Methods:**
- **getGreeting Method:**
```java
public String getGreeting() {
return greeting;
}
```
Returns the current greeting message.
- **getAreaCode Method:**
```java
public int getAreaCode() {
return areaCode;
}
```
Returns the current area code.
**Usage Example:**
When `setGreeting("Dan")` and `setAreaCode(464)` are executed, the output will be:
```
Voicemail: Hi, you have reached Dan at area code 464
```
**Diagram Explanation:**
The image provides a clear view of the code structure with interactive buttons labeled `MessageDetails.java` and `Message.java`, indicating separate Java files for organization and modularity in larger applications.
Transcribed Image Text:### Explanation of Code Snippet for Educational Purposes
#### Overview
The Java program consists of a class named `MessageDetails` that takes input for a greeting and an area code, and then prints a formatted voicemail message using these inputs.
#### Description
- **Classes and Methods**:
- The program imports the `Scanner` class for taking user input.
- The `MessageDetails` class contains the `main` method where the execution starts.
- An instance of the `Message` class is created, though the details of this class are not provided in the snippet.
- **Functionality**:
- The program first initializes a `Scanner` object to read input data.
- It then creates a `Message` object named `voicemail`.
- Two variables, `inputGreeting` and `inputAreaCode`, are used to store the user's input for the greeting and area code, respectively.
- The `inputGreeting` is read using `scnr.next()`, capturing a single word of input.
- The `inputAreaCode` is read using `scnr.nextInt()`, capturing a numerical value.
- **Code to Insert**:
- The placeholder `/* Your code goes here */` suggests that additional instructions are needed, likely involving calling the `setGreeting()` and `setAreaCode()` methods on the `voicemail` object to set these values.
- **Output**:
- The program outputs the formatted voicemail message:
```
Voicemail: Hi, you have reached [Name]
at area code [Code]
```
#### Example
If the input is `Dan 464`, the output will be:
```
Voicemail: Hi, you have reached Dan
at area code 464
```
This program illustrates object-oriented principles in Java, showcasing how to manipulate class fields and methods to format strings based on user input.
Expert Solution
Check MarkThis question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
bartleby
This is a popular solution
bartleby
Trending nowThis is a popular solution!
bartleby
Step by stepSolved in 5 steps with 3 images
Knowledge Booster
Background pattern image
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
- In java: containerdata.txt: 438118Vela7335 58025357780Guangzhou7821 49562228320Calumet8268 42566166336Canadian Miner8154 53127688309Empire MacMahon7148 78880272124Costa Marina8216 48293144769Carl D. Bradley7702 69160345120Baie Comeau7928 59558154640W.H. Gilcher7432 52093569191Burns Harbor7304 31962732239Mesabi Miner7906 52416579241SS Minnow7511 32289732723Western Reserve7457 55462342817Osaka Express7015 48816353071Gudrun Mrsk7965 20312110167Georgic8394 51067293443Gallic8294 44519621580Monterey7672 35540101609Napoli8385 58804376662Nuria7619 57902603981Pamela8022 96674603603Robert S Pierson7620 59019259076Sabrina7389 57665569887William C. Moreland8089 55155313818McKay5148 61598 Cargo Container Report. You will be producing a program which will allow the user to generate the container report on the following page in Container Number order or Ship Name order. The program will also the user to lookup the data for any given Container by number. The % cargo weight is the percentage of...arrow_forwardcodearrow_forwardonly Voicemail.java files can have input added inbetween lines 4 and 7. not in the gery code sections.arrow_forward
- Im trying ro read a csv file and store it into a 2d array but im getting an error when I run my java code. my csv file contains 69 lines of data Below is my code: import java.util.Scanner; import java.util.Arrays; import java.util.Random; import java.io.File; import java.io.FileNotFoundException; import java.io.FilenameFilter; public class CompLab2 { public static String [][] getEarthquakeDatabase (String Filename) { //will read the csv file and convert it to a string 2-d array String [][] Fileinfo = new String [69][22]; int counter = 0; File file = new File(Filename); try { Scanner scnr = new Scanner(file); scnr.nextLine(); //skips the label in the first row of the file while (scnr.hasNextLine()) { // this while loop will count the number of values in the usgs file counter += 1; // increases by one each time a line is read scnr.nextLine(); } while...arrow_forwardPlease rewrite all of this animation code so that it performs the same functions in a java file instead of the files .css,.js, and .html (which is what I have) in visual studios. You would need to import javaFX since this would require GUI. My styles.css and Animation.html are attached as screenshots, and my script.js is below: script.js const dialogue = [ { character: 'Narrator', text: "In the dead of night, beneath a moon veiled by misty clouds, a lone figure trudged along a desolate forest path." }, { character: 'Narrator', text: "Unknown to her, she was not alone." }, { character: 'Human', text: "Who's there? Show yourself!" }, { character: 'Creature', text: "You venture into realms unknown, mortal. What brings you to these woods?" }, { character: 'Human', text: "I seek passage to the village beyond. I mean no harm." }, { character: 'Creature', text: "Harm is but a shadow in these woods, mortal." }, { character: 'Human', text: "What do you mean? Who are...arrow_forwardNew JAVA code can only be added to Client.java file between lines of grey code (or between lines 2 and 4, as seen in image).arrow_forward
- Java Netbeansarrow_forwardJAVA PPROGRAM ASAP Please Modify this program ASAP BECAUSE IT IS HOMEWORK ASSIGNMENT so it passes all the test cases. It does not pass the test cases when I upload it to Hypergrade. Because RIGHT NOW IT PASSES 0 OUT OF 1 TEST CASES. I have provided the failed the test cases and the inputs as a screenshot. The program must pass the test case when uploaded to Hypergrade. import java.io.File;import java.io.FileNotFoundException;import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); String fileName; System.out.println("Please enter the file name or type QUIT to exit:"); fileName = keyboard.nextLine().trim(); while (!fileName.equalsIgnoreCase("QUIT")) { File file = new File(fileName); if (file.exists()) { int wordCount = countWords(file); System.out.println("Total number of words: " + wordCount + "\n);...arrow_forward1. Complete the class code below and include a method named "search" that takes two String parameters, a string to search and the other a target string to search for in the first string. The search method will return an integer representing the number of times the search string was found. The string being searched is a super-string formed by joining all lines of a text file, so we might expect to get multiple hits with our method. HINT: walk the String in a loop and use .substring(start, end) to examine a target-sized segment of the input string for equality to your target word. public class WordSearch { public static void main(String[] args) { String fileName String target = "help"; Scanner fileln = new Scanner(new File(fileName)); "story.txt"; %D String story = while(fileln.hasNextLine()) { story += fileln.nextLine(); // Build a super-String } System.out.printIn("(" + target + ") found "+ search(story, target) + " times"); } /l method code here } // end of WordSearch classarrow_forward
- In Java, create a user interface that has a top bar that includes a menu. The menu should have four items. When the user selects the first menu option, then the date and time should be printed in a text box. When the user selects the second menu option, then the text box contents should be written to a text file named "log.txt." When the user selects the third menu item then the frame background color changes to random color hue of the color green. The menu option should display the initial random hue each time selected for a single execution of the program. See https://www.w3schools.com/colors/colors_picker.asp When the user selects the fourth menu option then the program exits. Thank youarrow_forwardWrite a program that stores names and phone numbers from a text file in adictionary, with the name being the key. Write a method that does a reverselookup, that is, finds a name given a phone number. Write a Windowsapplication to test your implementation. code in c#arrow_forwardWrite code in JavaScript by following the instructions given below: A confirmation dialog box should be appeared right after the page load on the browser. When user press ok button from confirmation dialog box, a prompt dialog box will be shown with question "What is your institution name?" If user gives the answer "BIIT", an alert dialog box will be displayed in response with message "Right!" In case of any other answer, alert dialog box will be displayed in response with message "Wrong!"arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education