Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started