EBK JAVA PROGRAMMING
8th Edition
ISBN: 9781305480537
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
expand_more
expand_more
format_list_bulleted
Question
error_outline
This textbook solution is under construction.
Students have asked these similar questions
Briefly describe each of the following string object methods: a. Insert b. Remove c. ToLower d. ToUpper e. Trim f. TrimStart g. TrimEnd
Create an application with a method that accepts a string as an argument and returns the number of words it contains. For instance, if the argument is "Four score and seven years ago," the method should return the number 6. The application should let the user enter a string, and then it should pass the string to the method. The number of words in the string should be displayed.
Create an application that accepts a sentence as input and converts each word to “Pig Latin.” In one version, to convert a word to Pig Latin you remove the first let- ter and place that letter at the end of the word. Then you append the string "ay" to the word. Here is an example: English: I SLEPT MOST OF THE NIGHT Pig Latin: IAY LEPTSAY OSTMAY FOAY HETAY IGHTNAY
Knowledge Booster
Similar questions
- Which data type would be used to store 10.5 that you plan to add to another nubmber? A string B intenger C decimal D floatarrow_forwardConsider the following code. Answer questions 1 to 4. This is a walkthrough question #include <iostream> #include <cstring> using namespace std; const int NT = 10; const int NC = 2; class Chocolate { char type[NT + 1]; public: Chocolate(const char* t = nullptr) { if (t) { strncpy(type, t, NT); type[NT] = '\0'; } else { type[0] = '\0'; } cout << "C"; } ~Chocolate() { cout << "~" << type << endl; } void display() const { cout << type << endl; } }; class Box { Chocolate ch[NC]; int nc; public: Box() { nc = 0; cout << "B"; } Box& operator+=(const Chocolate& c) { if (nc < NC) { ch[nc] = c; cout << "+"; ch[nc++].display(); } return *this; } Box(const Box& b) { nc = b.nc; for (int i = 0; i <…arrow_forwardI wrote my code for this question: #include <iostream>using namespace std;class Player{ public: void setName(string a){name = a;} void setScore(int b){score = b;} string getName() const {return name;} int getScore() const {return score;} private: string name; int score; };int main(){ Player Guy; Guy.setName("Herb"); cout<<Guy.getName()<<" scored 10 points!\n"; Guy.setScore(10); cout<<"Score : "<<Guy.getScore(); return 0;} How to fix my problemarrow_forward
- When you want to know the position of the substring, you can use one of the __________ of a string object. a. TrimStart or TrimEnd methods b. IndexOf or LastIndexOf methods c. ToLower or ToUpper methods d. StartsWith or EndsWith methodsarrow_forwardUse method which take a string parameter. Method must be named hasRepeat and string parameter. Don't reject please And give me write code to fill. Attach screenshot as wellarrow_forwardWrite an application for Limpopo's Car Care Shop that shows a user a list of available services: oil change, tire rotation, battery check, or brake inspection. Allow the user to enter a string that corresponds to one of the options, and display the option and its price as R250, R220, R150, or R50, accordingly. Display an error message if the user enters an invalid item.The code must be visible!!!arrow_forward
- Help me correct my C++ code please! Pictures included. My current code with the error picture; #include <iostream> using namespace std; class Employee{ public: string first_name; string last_name; int monthly_sal; Employee() { first_name=""; last_name=""; monthly_sal=0; } void setFirst_Name(string first_name) { this->first_name=first_name; } void setLast_Name(string last_name) { this->last_name=last_name; } void setSal(int monthly_sal) { if(monthly_sal<0) this->monthly_sal=0; this->monthly_sal=monthly_sal; } string getFirst_Name() { return first_name; } string getLast_Name() { return last_name; } int get_salary() { return monthly_sal; } int get_yearly_salary() { return 12*monthly_sal; }}; int main(){ Employee ob; string first_name,last_name; int monthly_sal;…arrow_forwardCarly’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…arrow_forwardWhat will the following Code segment print on the screen? String LName = "FamilyName"; String FName = "GivenName"; System.out.println("Dear Mr " + LName); System.out.println("We would like to call you " + FName);arrow_forward
- the progam is : Public Class Form1Public Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click'Declare variablesDim vHeight As DecimalDim vWeight As DecimalDim vBMI As Decimal 'get and test values entered by user'tests user has entered a value for heightIf txbHeight.Text = “” Or txbWeight.Text = “” Then'Call error message sub procedureErrorMessage(“Please enter your height and weight in the box!”)Exit SubEnd If 'Calculate Body Mass initialize variablesvWeight = Val(txbWeight.Text)vHeight = Val(txbHeight.Text)'Calculate Body Mass Index ^ is for exponentsvBMI = vWeight / (vHeight ^ 2) 'Output message to Label txbResult.Text = vBMI Call ErrorMessage()End Sub Public Sub ErrorMessage() 'public sub for error msg box End Sub Public Sub ErrorMessage(errormsg As String) ' parameter for error messageMessageBox.Show(errormsg) 'to show the message boxEnd Sub Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnClose.Click 'close buttonClose() '…arrow_forward(3) Write a C# .NET Core Console App that asks the user to enter a number and then displays a string with the original number followed by the reverse of the number. For example, if the user entered 123 as an int you program should create a string "123321" and display it on the screenarrow_forward1. A showChar MethodWrite a method named showChar. The method should accept two arguments: a reference toa String object and an integer. The integer argument is a character position within theString, with the first character being at position 0. When the method executes, it shoulddisplay the character at that character position. The method does not return anything.Here is an example of a call to the method:showChar("New York", 2);In this call, the method will display the character w because it is in position 2. Demonstratethe method in a complete program-- use the class name Method_showChar Javaarrow_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,