(Solved) : Import Javautilscanner Public Class Lab4 Public Static Void Main String Args Scanner Input Q44031009 . . .
THIS IS WHAT I HAVE
import java.util.Scanner;public class Lab4 { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print(“Enter a line of text: “); // Enter your text String aLine = input.nextLine(); String temp = aLine.trim(); int num = aLine.length(); if (aLine.length() < 7) { System.out.println(“The input is too short”); } else { if (aLine.equals(temp)) { System.out.println(“the original String has no leading or trailing whitespace”); } else System.out.println(“the original String has leading or trailing whitespace.”); temp = aLine.substring(num – 5, num) + aLine.substring(2, num – 5) + aLine.substring(0, 2); //Swap the first two and last five characters of aLine and print the result. System.out.println(“First 2 and last 5 chars swapped: ” + temp); System.out.println(“to upper case: ” + aLine.toUpperCase()); // uppercase int mid = num / 2; if (num % 2 != 0) { System.out.println(“The line has an odd number of characters.”); } else { int middle1 = (num – 1) / 2; // first middle int middle2 = num / 2; // second middle char atMiddle1 = aLine.charAt(middle1); char atMiddle2 = aLine.charAt(middle2); System.out.println(“The two middle characters are ” + atMiddle1 + atMiddle2); } String low = aLine.toLowerCase(); System.out.println(“compareTo lower case version: ” + aLine.compareTo(low));//compare String firstHalf = aLine.substring(0, mid); String secondHalf = aLine.substring(mid + 1); System.out.println(“Does the fist half equal the last half? ” + firstHalf.equalsIgnoreCase(secondHalf));// dose first half equal second half } }}
The last thing that I have to do is
“Print aLine with one character removed: Thefirst ‘e’ ‘E’ ‘s’ or ‘S’.” So I will enter a text message and Iwant a program that will remove the first ‘e’ ‘E’ ‘s’ or ‘S’. And Ihave this constraint.
You may use ONLY String’s indexOf, charAt, length, compareTo,toUpperCase, toLowerCase, trim, equals, equalsIgnoreCase andsubstring methods. Sorry if it is hard to read my code. Currentlyworking on making it more organized.
Expert Answer
Answer to THIS IS WHAT I HAVE import java.util.Scanner; public class Lab4 { public static void main(String[] args) { Scanner input…
OR