Question: Software Construction - SE 4 1 1 Semester 2 0 2 Lab 5 - Best Practices Determine the bad practices of the following codes if
Software Construction SE
Semester
Lab Best Practices
Determine the bad practices of the following codes if any.
package palindrome;
import java.util.Scanner;
public class Palindrome
public static void mainString args
Scanner i new Scanner
System.in;
System.out.print lnEnter a number: ;
int inextInt ;
int orgInt ;
for ;;
;
int revint revint ;
if orgInt revint
System.out.printlnorgInt is not a palindrome.";
if orgInt revint
System.out.printlnorgInt is a palindrome.";
Bad practices:
Rewrite The code:
Pag e
Software Construction SE
Semester
Lab Best Practices
package palindrome;
import java.util.Scanner;
public class Palindrome
public static void mainString args
Scanner i new Scanner
System.in;
System.out.print lnEnter a number: ;
int inextInt;
int orgInt ;
for ;;
;
int revint revint ;
if orgInt revint
System.out.print orgInt is not a palindrome.";
if orgInt revint
System.out.print lnorgInt is a palindrome.";
Bad practices:
Rewrite the code :
P ag e
Software Construction SE
Semester
Lab Best Practices
package palindrome;
import java.util.Scanner;
public class Palindrome
public static void mainString args
Scanner input new Scanner
System.in;
System.out.print lnEnter a number: ;
int num input.nextInt ;
int remainder, originalinteger num;
for ; num ; num num
remainder num ;
int reversedinteger reversedinteger remainder;
if originalinteger reversedInteger
System.out.printlnoriginalinteger is not a palindrome.";
if originalinteger reversedinteger
System.out.printlnorignalinteger is a palindrome.";
Bad practices:
Rewrite Code :
Pag e
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
