Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 }} instructions:if the length is even the output should be the reversed first half and the (i)second half if the lengthis odd the output should be the reversed of the second half after the middle charachter (ii)the middle charachter of original string (iii) the reverse of the first half of the original string before the middle charachter
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle Database Architecture

Authors: Thomas Kyte, Darl Kuhn

3rd Edition

1430262990, 9781430262992

More Books

Students also viewed these Databases questions

Question

Do you consider yourself a people pleaser?

Answered: 1 week ago

Question

Am I providing feedback consistently?

Answered: 1 week ago