Prog 8.pdf

  • Uploaded by: Utsyo Chakraborty
  • 0
  • 0
  • October 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Prog 8.pdf as PDF for free.

More details

  • Words: 168
  • Pages: 2
Class ROTN 1 2 3 4 5 6

7 8 9 10 11 12

13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47

1/2

import java.io.*; class ROTN { public static void main()throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System .in)); String s; System.out.println("\nEnter the string"); s=br.readLine(); while(s.length()<3||s.length()>100)//validation { System.out.println("Invalid. Length of the string should be i n between 3 and 100. Re-enter"); s=br.readLine(); } System.out.println("Enter the rotation magnitude" ); int n=Integer.parseInt(br.readLine()); for(int i=0;i<s.length();i++) { char ch=s.charAt(i); if(ch==' '&&s.charAt(i-1)==' ') continue; else { if(ch=='#'||ch=='@'||ch=='$')//again validation! { int c=(int)ch; c=c-2; ch=(char)c; System.out.print(ch); } else if(ch<65||ch>122) System.out.print(ch); if(Character.isUpperCase(ch)==true) { int c=(int)ch; c=c+n; if(c>90)//conversion c=c-26; System.out.print((char)c); } else if(Character.isLowerCase(ch)==true) { int c=(int)ch; c=c+n; if(c>122) c=c-26; System.out.print((char)c); Jul 15, 2018 11:28:15 AM

Class ROTN (continued) 48 49 50 51 52

2/2

} } }//end of for-loop }//end of main() }//end of class

Jul 15, 2018 11:28:15 AM

Related Documents

Prog
December 2019 62
Prog
November 2019 57
Prog
May 2020 35
Prog.2
June 2020 6
Prog-perl
June 2020 6

More Documents from "Gerson Raymond"

Palimpsests Complete.pdf
October 2019 10
Prog 8.pdf
October 2019 15
Sarar Nowkaya Shuva-tusi
October 2019 14
Revised
October 2019 22
As 9
May 2020 7