In: Computer Science
Linux Question: you will practice on creating and editing a text file by VI.
How to:
$ sudo yum –y install java-1.8.0-openjdk-devel.x86_64
Here's the code
import java.util.Scanner; // Import the Scanner class class MollyHomework { public static void main(String[] args) { Scanner myObj = new Scanner(System.in); // Create a Scanner object System.out.println("Enter your first name"); String fName = myObj.nextLine(); // Read user input of the first name System.out.println("Enter your last name"); String lName = myObj.nextLine(); // Read user input of the last name System.out.println("Hello " + fName + “ “ + lName); // Output user input } } |
3.To compile the above java code, run the following command (you need to use your java file name):
$ javac MollyHomework.java
4. To execute the java program, run the following command
$ java MollyHomework
Question:
Describe how you created above file and its contents in VI.
Note: Brute-force solution means that entering characters one by one.
*Show how the code looks or how you got it to work in your linux machine
Type the above program in notepad or just copy it and then paste it in VI editor with the following method.
the first type I for insert text.
Move the cursor to the end of what you want to cut. Press d to cut (or y to copy). Move to where you would like to paste. Press P to paste before the cursor, or p to paste after.
if you have any doubt then please ask me without any hesitation in the comment section below, if you like my answer then please thumbs up for the answer, before giving thumbs down please discuss the question it may possible that we may understand the question in a different way and I can edit and change the answers if you argue, thanks :)