Given three String variables that have been declared and given values, firstName, middleName, and lastName, write an expression whose value is the values of each these variables joined by a single space. So if firstName, middleName, and lastName, had the values "Big", "Bill", and "Broonzy", the expression's value would be "Big Bill Broonzy". Alternatively, if firstName, middleName, and lastName, had the values "Jerry", "Lee", and "Lewis", the expression's value would be "Jerry Lee Lewis"

Respuesta :

import java.util.Scanner;

public class Main{

static String firstName;

static String middleName;

static String lastName;

public Main(String firstName, String middleName, String lastName){

this.firstName = firstName;

this.middleName = middleName;

this.lastName = lastName;

}

public void printFullName(){

 System.out.println(firstName + " " + middleName + " " + lastName);

}

public static void main(String...args){

Scanner input = new Scanner(System.in);

// System.out.println("Enter a name seperated by spaces");

// firstName = input.next();

// middleName = input.next();

// lastName = input.next();

firstName = "John";

middleName = "Michael";

lastName = "Scott";

Main obj1 = new Main(firstName, middleName, lastName);

obj1.printFullName();

}

}

ACCESS MORE