I need the solution for FixDebugSix2.java and it\'s not posted in Chegg Answers.
ID: 3759220 • Letter: I
Question
I need the solution for FixDebugSix2.java and it's not posted in Chegg Answers. The coding is from the file listed in Java Programming Joyce Farrel 7th Edition, Problem is on Page # 346, under Debugging Exercise. Here is a copy of the file:
// DebugSix2.java
// Display every character between Unicode 65 and 122
// Start new line after 20 characters
public class DebugSix2
{
public static void main(String args[])
{
char letter;
int a;
final int MIN = 65;
final int MAX = 122;
final int STOPLINE1 = 85;
final int STOPLINE2 = 122;
for(a = MIN; a <= MAX; a++)
letter = (char)a;
System.out.print(" " + letter);
if((a == STOPLINE1) & (a == STOPLINE2))
System.out.println();
System.out.println(" End of application")
}
}
Explanation / Answer
// DebugSix2.java
/* The java program that display every character between Unicode 65 and 122
* that prints a new line after 20 characters
*/
public class DebugSix2
{
public static void main(String args[])
{
char letter;
int a;
final int MIN = 65;
final int MAX = 122;
//To print a new line after 20 characters,65+20=85
final int STOPLINE1 = 85;
//Then after 20 characters ,85+20=105
final int STOPLINE2 = 105;
for(a = MIN; a <= MAX; a++)
{
//print a accii characer of a
letter = (char)a;
System.out.print(" " + letter);
/*Check the condition if a is STOPLINE1
or a is STOPLINE2 then print a new line.
Print STOPLINE1 is 65 or STOPLINE2 is 105
*/
if((a == STOPLINE1) || (a == STOPLINE2))
System.out.println();
}
System.out.println(" End of application");
}
}
------------------------------------------------------------------------------------------------------------------------------------------------------------
Sample Output:
A B C D E F G H I J K L M N O P Q R S T U
V W X Y Z [ ] ^ _ ` a b c d e f g h i
j k l m n o p q r s t u v w x y z
End of application
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.