38.1k views
5 votes
Write a Program that prints a given string in reverse order using a while loop

Use that same program to check if the given string is a pallindrome or not?

USE JAVA PLS
75 POINTS NEED QUICK PLEASE

1 Answer

1 vote

import java.util.*;

class HelloWorld {

public static void main(String[] args) {

System.out.println("Please enter a string: ");

Scanner idx = new Scanner(System.in);

String f = idx.nextLine(),n="";

int c=0;

while(c<f.length()) {

char temp = f.charAt(c);

n=temp+n;

c++;

}

System.out.println("Reversed: "+n);

}

}

User FireAlkazar
by
5.2k points