Question: import java.util.Scanner; // Moe Hamam // Class definition for Classmates class Classmates { // Private properties to store the names private String name1; private String

import java.util.Scanner;

// Moe Hamam

// Class definition for Classmates

class Classmates {

// Private properties to store the names

private String name1;

private String name2;

private String name3;

// Constructor to initialize the properties with input values

public Classmates(String name1, String name2, String name3) {

// Assign the input values to the properties

this.name1 = name1;

this.name2 = name2;

this.name3 = name3;

}

// Getter method to return the two classmates

public String[] classmates() {

// Create an array to store the classmates

String[] classmates = new String[2];

// Assign the second and third names to the array

classmates[0] = name2;

classmates[1] = name3;

// Return the array

return classmates;

}

}

// Main class definition

public class Main {

// Main method

public static void main(String[] args) {

// Create a Scanner object to read user input

Scanner scan = new Scanner(System.in);

// Prompt the user to enter the first name

System.out.println("Enter the first name: ");

// Read the first name

String name1 = scan.nextLine();

// Prompt the user to enter the second name

System.out.println("Enter the second name: ");

// Read the second name

String name2 = scan.nextLine();

// Prompt the user to enter the third name

System.out.println("Enter the third name: ");

// Read the third name

String name3 = scan.nextLine();

// Create an instance of the Classmates class with the input names

Classmates classmates = new Classmates(name1, name2, name3);

// Call the classmates getter method and store the result

String[] classmatesList = classmates.classmates();

// Print the classmates

System.out.println("The classmates are " + classmatesList[0] + " and " + classmatesList[1]);

}

}

**** my question is what can language program can i run that code on it ?

can you run it and give the result screenshot and use the variable names is Moe, raj, cliff

thank you for any help

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!