Write a program to test your class MyStringTest. import java.util.Scanner; class
ID: 3540553 • Letter: W
Question
Write a program to test your class MyStringTest.
import java.util.Scanner;
class MyStringTest {
public static void main(String[] args){
String str ;
Scanner keyboard = new Scanner(System.in);
//Enter String Input
System.out.print("Enter string:");
str = keyboard.nextLine();
//Reverse Order
System.out.print("The Reverse order is:");
for (int i= str.length()-1; i >= 0; i--)
System.out.print(str.charAt(i));
//Exit Program
System.exit(0);
}
}
Explanation / Answer
// testing below program.
// save below file as MyStringTest.java
// compile as javac MyStringTest.java
// now run java MyStringTest
// now it asks for Enter string:
// give any string name for ex. Aswani
// now it prints The Reverse order is: inswsA
// thats it program is TESTED.
// if u need any help let me know
import java.util.Scanner;
class MyStringTest {
public static void main(String[] args){
String str ;
Scanner keyboard = new Scanner(System.in);
//Enter String Input
System.out.print("Enter string:");
str = keyboard.nextLine();
//Reverse Order
System.out.print("The Reverse order is:");
for (int i= str.length()-1; i >= 0; i--)
System.out.print(str.charAt(i));
//Exit Program
System.exit(0);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.