Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

8. Write a sequence of Java statements to match the description in the following

ID: 3664359 • Letter: 8

Question

8. Write a sequence of Java statements to match the description in the following comments: //declare a String variable to represent the user’s surname //and another String variable to represent the user’s other name //prompt the user for his/her surname, and then input a value for the surname //prompt the user for his/her other name, and then input a value for the other name //output a message of a form: Hello x! You belong to the y family //where x is the value of the other name variable, and y is the value of the surname variable

Explanation / Answer

<code>

import java.util.Scanner;


public class rand {
   public static void main(String[]args){
       Scanner in = new Scanner(System.in);
       String userSurname;
       String userOtherName;
       String othername;
       System.out.print("Surname:");
       userSurname = in.nextLine();
       System.out.println("OtherName");
       userOtherName = in.nextLine();
       System.out.println("Hello "+userOtherName+"! You belong to the "+userSurname+" family");
   }
}

</code>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote