Question: Heres my code please fix the logical error when the user enters Not visible which is odd he should get elbisiv toN but he doesnt

Heres my code please fix the logical error when the user enters Not visible which is odd he should get elbisiv toN but he doesnt get the desired output please work on the code and follow the instructuon to make him get the correct outputWelcome to Concordia CSSE Drone Cipher Program:
+++++++++++++++++++++++++++++++++++++++++++++++
Please enter your plain message below:
elbisiv toN
Kindly find below your cipher message output:
Not visible
Thank you for your contribution to Concordia CSSE Drone Cipher Project.
Figure 3. Sample-3 output of Question 1
Welcome to Concordia CSSE Drone Cipher Program:
+++++++++++++++++++++++++++++++++++++++++++++++
Please enter your plain message below:
A big black object is moving!
Kindly find below your cipher message output:
! gnivom si tcejbo kcalb gib A
Thank you for your contribution to Concordia CSSE Drone Cipher Project.
Figure 4. Sample-4 output of Question 1
Welcome to Concordia CSSE Drone Cipher Program:
+++++++++++++++++++++++++++++++++++++++++++++++
Please enter your plain message below:
! gnivom si tcejbo kcalb gib A
Kindly find below your cipher message output:
A big black object is moving!
Thank you for your contribution to Concordia CSSE Drone Cipher Project.
Figure 5. Sample-5 output of Question 1 Assignment (3)// Written by: (Mena Boulus 40291619)// For COMP 248 Section (UJ-X) Winter 2024//--------------------------------------------------------------------import java.util.Scanner; // Importing the Scanner class from java.util package for user inputpublic class A3_Q1{// Declaring a public class named A3_Q1 public static void main(String[] args){ Scanner mena = new Scanner(System.in); // Creating a Scanner object for user input System.out.println("Welcome to Concordia CSSE Drone Cipher Program:"); // Printing a welcome message System.out.println("++++++++++++++++++++"); System.out.println("Please enter your plain message below:"); // Prompting the user to enter a message String Encodeven =""; // Declaring an empty string variable for even-indexed characters String Encodeodd =""; // Declaring an empty string variable for odd-indexed characters String Original = mena.nextLine(); // Reading user input and storing it in a string variable Original.strip(); // Stripping to create whitespaces from the input if (Original.length()%2==0){// Checking if the length of the input string is even int x = Original.length()-1; // Initializing a variable for loop iteration while (x > Original.length()/2-1){// Looping through the even-indexed characters char y = Original.charAt(x); // Getting the character at the current index Encodeven += y; // Assigning it to Encodeven string x--; // Decrementing the index }} else {// Executed if the length of the input string is odd int z = Original.length()-1; // Initializing a variable for loop iteration while (z >= Original.length()/2){// Looping through the odd-indexed characters char y = Original.charAt(z); // Getting the character at the current index Encodeodd += y; // Assigning to the Encodeodd string z--; // Decrementing the index } System.out.println(Encodeodd); // Printing the odd-indexed characters } if (Original.length()%2==0){// Checking if the length of the input string is even Encodeven += Original.substring(0, Original.length()/2); // Appending the first half of the input string to Encodeven System.out.println("
Kindly find below your cipher message output:"); // Printing a message System.out.println(Encodeven); // Printing the cipher message for even-length input } System.out.println("
Thank you for your contribution to Concordia CSSE Drone Cipher Project."); // Printing a thank you message mena.close(); // Closing the Scanner object to release system resources }}
 Heres my code please fix the logical error when the user

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!