
Concept explainers
8.4 Let s1 be " Welcome " and s2 be " welcome ". Write the code for the following
statements:
(a) Check whether s1 is equal to s2 and assign the result to a Boolean variable
isEqual.
(b) Check whether s1 is equal to s2, ignoring case, and assign the result to a
Boolean variable isEqual.
(c) Check whether s1 has the prefix AAA and assign the result to a Boolean variable b.
(d) Check whether s1 has the suffix AAA and assign the result to a Boolean variable b.
(e) Assign the length of s1 to a variable x.
(f) Assign the first character of s1 to a variable x.
(g) Create a new string s3 that combines s1 with s2.
(h) Create a substring of s1 starting from index 1.
(i) Create a substring of s1 from index 1 to index 4.
(j) Create a new string s3 that converts s1 to lowercase.
(k) Create a new string s3 that converts s1 to uppercase.
(l) Create a new string s3 that trims whitespace characters on both ends of s1.
(m) Replace e with E in s1.
(n) Assign the index of the first occurrence of character e in s1 to a variable x.
(o) Assign the index of the last occurrence of string abc in s1 to a variable x.

Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images

- 5. Let Q (x,y) denote the statement " the words x iff y contain the letter 'o'. What are the truth values for the following? Part A: Q (babies, drool) Part B: Q (cheese, mouse) Part C: Q (worm, brook) Part D: Q (orange, banana) Part E: Q (peaches, cherries)arrow_forwardPlease read the instructions carefully: This is a Java programarrow_forwardWhich of the following R.Es are equivalent?? I. (00)* (Λ+0) II. 0* III. 0(00)* IV. (00)* a) I &II ……? b) II & III…..? c) I & III….? d) III & IV..?arrow_forward
- Please Solve, Thank You! 3.18.2: Read in a time and print the equivalent military hour. Read in a time such as 3 pm and print the equivalent military hour (such as 15). Validate the input. If the input doesn't start with an integer, print: Error: Not an integer. If the number isn't between 1 and 12, print: Error: The hour must be between 1 and 12. If the suffix isn't "am" or "pm", print: Error: The suffix must be am or pm. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 import java.util.Scanner; public class TimeReader { publicstaticvoidmain(String[] args) { Scannerin=newScanner(System.in); if (/* Your code goes here */) { inthour=in.nextInt(); if (/* Your code goes here */) { Stringsuffix=in.next(); if (/* Your code goes here */) { /* Your code goes here */ //Convert hour to military time import java.util.Scanner; public class TimeReader{ public static void main(String[] args) { Scanner in = new Scanner(System.in); if (/* Your code…arrow_forwardSolve this using JavaScriptarrow_forwardPlease answer question. This is pertaining to Java programming language 1-21arrow_forward
- Write an if-else statement to describe an object. Print "Balloon" if isBalloon is true and isRed is false. Print "Red balloon" if isBalloon and isRed are both true. Print "Not a balloon" otherwise. End with newline. (Notes) 345154 2174782.qx3zgy7 1 #include 2 using namespace std; 3. 4 int main() { bool isRed; bool isBalloon3B 6. cin >> isRed%3; cin >> isBalloon; 8 10 11 if (isBallon= D 12 13 return 0; 14 }arrow_forwardpyhon explainarrow_forwardHelp, please.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





