Page 609 - ComputerScience_Class_11
P. 609
45 {
46 System.out.println(num + " is not a Bouncy Number.");
47 System.exit(0);
48 }
49 }
50 }
The output of the preceding program is as follows:
BlueJ: Terminal Window - Java
Options
Enter a number: 546
546 is a Bouncy Number.
Program 22 Write a program in Java to accept a string and display the new string after reversing the
characters of each word.
Sample Input:
Understanding Computer Science
Sample output:
gnidnatsrednU retupmoC ecneicS
class name : strrev
Data Members
String str : Stores the original string
String nwstr : Stores the new String
int len : Length of the String
Member Methods
void input() : Inputs the new String in "str"
void reverse() : Reverses the string in "nwstr"
void display() : Prints both the strings
1 import java.util.*;
2 class strrev
3 {
4 String str,nwstr;
5 void input()
6 {
7 int len;
8 Scanner sc = new Scanner(System.in);
9 System.out.println("Enter a string:");
Internal Assessment 607

