EBK JAVA PROGRAMMING
8th Edition
ISBN: 9781305480537
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
expand_more
expand_more
format_list_bulleted
Concept explainers
Expert Solution & Answer
Chapter 7, Problem 9RQ
<PROGRAM-DESCRIPTION-ANSWER>
The expression name1.compareTo(name2) contains the value “-1”.
Hence, the correct option is “C”.
</PROGRAM-DESCRIPTION-ANSWER>
Explanation of Solution
Given:
String name1 = new String ("Jordan");
String name2 = new String ("Jore");
To find:
name1.compareTo (name2)
Explanation:
- Here, “name1” is the string variable and assign with a string value “Jordan”.
- The “name2” is the string variable and assign with a string value “Jore”...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Can you please clean up my code? Because i think there is an implementation problem in the middle. Thank you.
I have attached the airportqueuedata.txt as a screenshot.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void enqQ(int&);
void deqQ(int&);
void clearQ(int&, int&);
bool isEmpty(int, int);
bool isFull(int, int);
struct planes // data type plane declared via struct
{
stringrequest;
stringflightNum;
stringstartingPoint;
stringdestination;
stringnumberOfPassengers;
};
void enqQ(int& rear) // adds data to queue
{
rear = (rear + 1) % 10;
}
void deqQ(int& front) // delets data from queue
{
front = (front + 1) % 10;
}
void clearQ(int& front, int& rear) // clears queue
{
front = -1;
rear = -1;
}
bool isEmpty(int front, int rear) // tells if queue is empty or not
{
if (rear == front)
return true;
else
return false;
}
bool isFull(int front, int rear) // tells if queue is full or not
{
if…
I have the following JAVA code using JFRAME:
String[] headers = {"Username", "First Name", "Middle Name", "Last Name"};
JSONArray jsonArray = readJSONFile("src/registration.json");for (int i = 0; i < jsonArray.size(); i++) {JSONObject obj = (JSONObject) jsonArray.get(i);String uName = (String) obj.get("username");String fName = (String) obj.get("firstName");String mName = (String) obj.get("middleName");String lName = (String) obj.get("lastName");Object[] row = {uName, fName, mName, lName};tableModel.addRow(row);}
My code displays data for each registrant in a table format. Please add an action listener to my GUI code that will delete the selected data from the JSON file.
I have the following JAVA code using JFRAME:
String[] headers = {"Username", "First Name", "Middle Name", "Last Name"};
JSONArray jsonArray = readJSONFile("src/registration.json");for (int i = 0; i < jsonArray.size(); i++) {JSONObject obj = (JSONObject) jsonArray.get(i);String uName = (String) obj.get("username");String fName = (String) obj.get("firstName");String mName = (String) obj.get("middleName");String lName = (String) obj.get("lastName");Object[] row = {uName, fName, mName, lName};tableModel.addRow(row);}
My code displays data for each registrant in a table format. Please add an action listener to my GUI code that will write the data of the selected row to a separate JSON file.
Knowledge Booster
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
- Imagine that you have a String variable named myString that references the value "Hello World", and a second String variable named myOtherString. After the statement "myOtherString = myString.toUpperCase();", what would the result of myString.charAt(8) be?arrow_forwardWrite an application that reads a five-letter word from the user and produces every possible three-letter string that can be derived from the letters of that word. For example, the three-letter words produced from the word “bathe” include “ate,” “bat,” “bet,” “tab,” “hat,” “the” and “tea.”arrow_forwardHow many String objects are created by the following declaration? String[] labels = new String[20];arrow_forward
- Write a program in the StringManipulator class that creates a String variable that references a String object holding the name of your favorite city. The program should display the following: • The number of characters in the city name• The name of the city in all uppercase letters • The name of the city in all lowercase letters • The first character in the name of the cityarrow_forwardUsing Java, Write a program with text fields and two button labeled “Ucase” for uppercase and ”Lcase” for lowercase. The user enters a string into the text field. When the user clicks on the uppercase button, the string changes to uppercase: when the user clicks on the lowercase button, the string changes to lowercase. The result will be displayed using a label component. toLowerCase() toUpperCase()arrow_forwardCreate two objects of DateTime using two different dates so each date has the Year, Month, Day, Hour, and Minutes. Then write a code which checks if the Month of either of the two dates is same as the Month of the current time now, assign Yes to a variable checker when they are same, otherwise No. The language Code is Visual C#arrow_forward
- 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.arrow_forwardWrite 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. Write Java code 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 } }arrow_forwardPlease answer the correct option and its reasoning. int loc; String str = "The cow jumped over the moon."; loc = str.indexOf("ow"); What is the value of loc? 1. 5 2. 6 3. 4 4. 7arrow_forward
- IN JAVA When people enter their telephone numbers into a form they use many different formats. Some examples are: (444) 999-1234 4449991234 444.999.1234 In the PhoneNumbers class below, complete the cleanNumber method. It takes a string and extracts the numeric digits from the string. If there are exactly 10 numeric digits, the number is reformatted: (###) ###-#### and returned. If there are any other number of digits, the string "Error" is returned. Hint: Use the Character.isDigit method to check whether a character is a digit. public class PhoneNumbers{ /** Cleans a phone number. @param phoneNumber a phone number that should contain ten digits and possibly other characters @return the phone number in the form (###) ###-#### or the string "Error" if phoneNumber does not have ten digits */ public String cleanNumber(String phoneNumber) { // your work here ... for (int i = 0; i < ...; i++) { char ch = phoneNumber.charAt(i);…arrow_forwardCreate an application that reads a sequence of up to 25 names and postal (ZIP) codes for persons. Put the data in an object that can have a first name (string), last name (string), and postal code (integer). Assume that each line of input will have two strings separated by a tab character, followed by an integer value. After the input has been read in, print the list to the screen in the appropriate manner.arrow_forward(Java) What will the following display to the console? Work out the solution by hand (don't run the code, until after you have worked it out by hand). StringBuilder sb1 = new StringBuilder("Cat");StringBuilder sb2 = new StringBuilder(sb1.replace(2, 3, "Rat").append("Mat"));sb2.append("Sat!");System.out.println(sb1);System.out.println(sb2);arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage