Homework Solution: Retype and correct the code provided to combine two strings separated by a space. secret ID. contact (spaceChar): secret ID. contact (lastName): 1 im…

    @@@ < >肛 learn.zybooks.com ○山。 Lab 2 Post Test: COMPUTER SCIENCEICSC Computer Sclence question Chegg.com 3.9. String modify operations uava浂于初蛤化boolean值的问题百度知道 响 chegg Study l Gulded Solutions and Study- zyBooks Library>CSCE 155A home >3.9:String modify operations @ Help/ FAQ θ BojunZhong ▼ 搜索 ☆个人收藏 CHALLENGE3,9.1: Combining strings. ACTIVITY IMG 0264.JPG 4-5学生选课 添加课程11 (0 F22BB179-E979-46F2-AAO9... 20E74856-C898-4889-85A Retype and correct the code provided to combine two strings separated by a space. secretID.concat (spaceChar) secretID.concat (lastName); 1 import java.util.Scanner; 3 public class CombiningStrings f 4 public static void main (String args) [ String secretIDBarry; String lastName Allen char spaceChar secretID.concat(spaceChar) 10 secretID.concat(lastName); 12 13 14 15 System.out.println(secretID); return; Failed to compile CombiningStrings.java:9: concat (java.lang.String) in java.lang.String cannot be applied to (char)
    Retype and correct the code provided to combine two strings separated by a space. secret ID. contact (spaceChar): secret ID. contact (lastName): 1 important java.util.Scanner { 2 3 public class CombiningStrings { 4 public static void main (String argus) { 5 String secretID = "Barry" 6 String lastName = "Allen": 7 char spaceChar = ' ': 8 9 secretID.concat(spaceChar): 10 secretID.concat(lastName): 11 System.Out.Println (secretID): 13 return: 14 } 15 }

    Expert Answer

     
    import java.util.Scanner;

    @@@ < >肛 acquire.zybooks.com ○山。 Lab 2 Post Test: COMPUTER SCIENCEICSC Computer Sclence interrogation Chegg.com 3.9. String deviate operations uava浂于初蛤化boolean值的问题百度知道 响 chegg Study l Gulded Solutions and Study- zyBooks Library>CSCE 155A settlement >3.9:String deviate operations @ Help/ FAQ θ BojunZhong ▼ 搜索 ☆个人收藏 CHALLENGE3,9.1: Combining strings. ACTIVITY IMG 0264.JPG 4-5学生选课 添加课程11 (0 F22BB179-E979-46F2-AAO9... 20E74856-C898-4889-85A Remold and improve the method supposing to cohere couple strings disjoined by a intervenience. concealedID.concat (spaceChar) concealedID.concat (lastName); 1 purport java.util.Scanner; 3 notorious rank CombiningStrings f 4 notorious static unoccupied main (String args) [ String concealedIDBarry; String lastName Allen char intervenienceChar concealedID.concat(spaceChar) 10 concealedID.concat(lastName); 12 13 14 15 System.out.println(secretID); return; Failed to settle CombiningStrings.java:9: concat (java.lang.String) in java.lang.String cannot be applied to (char)

    Remold and improve the method supposing to cohere couple strings disjoined by a intervenience. concealed ID. touch (spaceChar): concealed ID. touch (lastName): 1 purportant java.util.Scanner { 2 3 notorious rank CombiningStrings { 4 notorious static unoccupied main (String argus) { 5 String concealedID = “Barry” 6 String lastName = “Allen”: 7 char intervenienceChar = ‘ ‘: 8 9 concealedID.concat(spaceChar): 10 concealedID.concat(lastName): 11 System.Out.Println (secretID): 13 return: 14 } 15 }

    Expert Counterpart

     

    purport java.util.Scanner;
    notorious rank CohereStrings
    {
    notorious static unoccupied main(String args[])
    {
    String concealedID=”Barry”;
    String lastName=”Allen”;
    String spaceChar=” “;                    //we possess to make spaceChar a String because by concat(),we can link Strings only
    secretID=secretID.concat(spaceChar);        // it earn link spaceChar with secretID
    secretID=secretID.concat(lastName);           // it earn link lastName with secretID
    System.out.println(secretID);              // it earn stereomold the prize of secretID
    }
    }

    OUTPUT OF THIS CODE IS :

    NOTE : A character prize can’t be linkd by concat() with a String mold Prize.That’s why we made spaceChar variable as a String so that we can largely link it with secretID