Menu

[Solved]Java Program Trying Fix Code Output Getting Output Want Q37170831

Java program. Trying to fix my code:

import java.util.Scanner public class StringExercise public static void main(String args) Scanner scan-new Scanner(System. in

This is the output I am getting:

run StringExercise Enter a line of text with at least 3 characters: lucky The first char is: The last char is: y The first ha

This is the output I want:

Welcome to DrJava. Working di run StringExerciseSolution Enter a line of text containir lucky The first character is: 1 The l

import java.util.Scanner public class StringExercise public static void main(String args) Scanner scan-new Scanner(System. in); System.out.println( Enter a line of text with at least 3 characters:”) String message – scan.nextLineO; char firstChar message.charAt( char lastChar message.charAt(message.length)-1); char firstHalf message.charAt(message.lengthO/2); char lastHalf message.charAt (message.length)/2D; System.out.printlnC The first char is: “+firstChar) System.out.printlnC”The last char is: “+lastChar); System.out.printlnC The first half is: “+firstHalf); System.out.printlnC The last half is: “+lastHalf); run StringExercise Enter a line of text with at least 3 characters: lucky The first char is: The last char is: y The first half is: c The last half is: c Welcome to DrJava. Working di run StringExerciseSolution Enter a line of text containir lucky The first character is: 1 The last character is: y The first half is: lu The last half is: cky Show transcribed image text import java.util.Scanner public class StringExercise public static void main(String args) Scanner scan-new Scanner(System. in); System.out.println( Enter a line of text with at least 3 characters:”) String message – scan.nextLineO; char firstChar message.charAt( char lastChar message.charAt(message.length)-1); char firstHalf message.charAt(message.lengthO/2); char lastHalf message.charAt (message.length)/2D; System.out.printlnC The first char is: “+firstChar) System.out.printlnC”The last char is: “+lastChar); System.out.printlnC The first half is: “+firstHalf); System.out.printlnC The last half is: “+lastHalf);
run StringExercise Enter a line of text with at least 3 characters: lucky The first char is: The last char is: y The first half is: c The last half is: c
Welcome to DrJava. Working di run StringExerciseSolution Enter a line of text containir lucky The first character is: 1 The last character is: y The first half is: lu The last half is: cky

Expert Answer


Answer to Java program. Trying to fix my code: This is the output I am getting: This is the output I want: … . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *