EBK JAVA PROGRAMMING
8th Edition
ISBN: 9781305480537
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
error_outline
This textbook solution is under construction.
Students have asked these similar questions
Please 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. 7
Which of the following is NOT valid Javascript code?
a.
let String myString = "Hello!";
b.
const smallNum = 2n;
c.
a = 5;b = 6;var a, b;
d.
let a, b;
a = 5;b = 6;
e. const bigNum = 123456789012345678901234567890123456789012345678901234567890n;
f. let myArray = [ null, undefined, "This", 4 ];
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.
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
- 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.arrow_forwardSuppose s1 and s2 are two strings. Which of the following statement or expression is valid in Java ? a - String s3 = s1 + s2; b - s1 >= s2; c - int i = s1.length; d - s1.charAt(0) = '5';arrow_forwardWhat is the value of the String S after the following line? String S, s1 ="arach",s2 = "nophobia” ; S =s1.substring(0,2) +s2.substring(3); a. "arachobia" b. "arnophobia" c. "rachobia" d. "arhobia"arrow_forward
- 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_forwardExplain the following code and what is the previous method? public void OnSend(View v){ String phoneNumber = number.getText().toString(); String smsmessage = message.getText().toString(); if(phoneNumber == null || phoneNumber.length() == 0 || smsmessage == null || smsmessage.length() == 0){ return; } if(checkPermission(Manifest.permission.SEND_SMS)){ SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(phoneNumber, null, smsmessage, null, null); Toast.makeText(this, "Message sent", Toast.LENGTH_SHORT).show(); } Question 2: Explain the following code: button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); XFragment xfragment = new XFragment();…arrow_forwardConsider you are given a very specialized string with a unique format as: Quiz_(no) # (q.no) : (question statement) $ (option1) , (option 2) , … * (right option number) … \n String starts with Quiz_ (quiz number like 1, 2, … ), then hash #, then question number (like qno_1, qno_2 …), then colon :, then question statement, then dollar $, then options (like option1, option 2 …), then asterisk *, and then right option for the given question statement. If more questions are there for the same quiz, then pattern after hash # is repeated (means every question is separated by # symbole). Each quiz ends with new line (\n), and then new quiz starts with same pattern as before. A sample pattern is given below. You are required to create a program in JAVA, in such a way that if your program receives any string with this pattern (or format) it should provide output as given below. (Hint: Use split, trim method to do the job) String starts with Quiz_ (quiz number like 1, 2, … ), then hash #, then…arrow_forward
- Consider you are given a very specialized string with a unique format as: Quiz_(no) # (q.no) : (question statement) $ (option1) , (option 2) , … * (right option number) … \n String starts with Quiz_ (quiz number like 1, 2, … ), then hash #, then question number (like qno_1, qno_2 …), then colon :, then question statement, then dollar $, then options (like option1, option 2 …), then asterisk *, and then right option for the given question statement. If more questions are there for the same quiz, then pattern after hash # is repeated (means every question is separated by # symbole). Each quiz ends with new line (\n), and then new quiz starts with same pattern as before. A sample pattern is given below. Quiz_1# qno_1: What comes next to First $first, second, third, fourth *2 # qno_2: What comes before second $first, second, third, fourth, fifth *1 \nQuiz_2# qno_1: What is liquid $water, bread, smoke *1 # qno_3: What is hot $ice-cream, candies, spices *3 You are required to create a…arrow_forwardCan 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…arrow_forwardWhat will be the output of given JavaScript code segment? var myNum = 15;console.log(myNum.toString(8)); Explain as well.arrow_forward
- What is wrong with the following program? #include <iostream> //Line 1using namespace mySpace //Line 2{ //Line 3const double PRIZE = 50000.00; //Line 4int x; //Line 5} //Line 6 using namespace std; //Line 7int main() //Line 8{ //Line 9double num; //Line 10num = 2 * PRIZE; //Line 11mySpace::x = static_cast<num>; //Line 12cout << PRIZE << " "…arrow_forwardI have this code ( C#): there is an error, as in attached, What is the problem? >>>>>>>>>>>>>>>>>>>>>>>>>>>> using System;public class Rectangle{ double width, length, coorx, coory; public Rectangle() { width = 1; length = 1; coorx = 0; coory = 0; } public void move(double x, double y) { coorx += x; coory += y; } public double getArea() { return width * length; } public double getPerimeter() { return 2 * (width + length); } public override string ToString() { return "Rectangle with width: " + width.ToString() + ", length: " + length.ToString() + " with its center at : (" + coorx.ToString() + ", " + coory.ToString() + ")\n"; } public static void Main() { Rectangle[] arr = new Rectangle[2]; arr[0] = new Rectangle(); arr[1] = new Rectangle(3,4,0,0);…arrow_forwardWrite a program that reads the user's first name and last name, and then use them to create a UPM email for the user. If the total number of characters in the user's full name, (first name + last name), is less than 10 letters, you should use the full name to create the user’s email. The general format of the user’s email should look like this: firstName.lastName@upm.edu.sa For example: First name = Ali Last name = Omar Total number of letters in both first and last names = 7 letters (<10 letters) Output = omar.ali@upm.edu.sa If the number of characters in the user's full name, (first name + last name), is greater than or equal to 10 letters, you should only use the first character in the user’s first name, and the whole last name to create an email. For example: First name = Abdullah Last name = Omar Total number of letters in both first and last names = 12 letters (>=10 letters) Output = a.omar@upm.edu.sa Note: you can assume the user will always enter lowercase lettersarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,