Question
Exercise 05.15 (Introduction to Java, Programming and Data Structures) (Display the ASCII character table) Write a program that prints the characters in the ASCII character
Exercise 05.15 (Introduction to Java, Programming and Data Structures)
(Display the ASCII character table) Write a program that prints the characters in the ASCII character table from ! to ~. Display 10 characters per line. The ASCII table is given in Appendix B. Characters are separated by exactly one space.
This is my current code.
public class Exercise05_15{ public static void main (String[] args){ //storing the starting ASCII character within "letter" char letter = '!'; //this will be my counter for a set number of loops int count = 0; //int a = 2; //Loop to print out the correct number of ASCII characters while (count < 95) { System.out.print(letter++); System.out.print(" "); count++; //If statement to return to the next line after ten characters if (count == 10 || count == 20 || count == 30 || count == 40 || count == 50 || count == 60 || count == 70 || count == 80 || count == 90) System.out.println(""); } } }
It currently runs and displays the table correctly but my teacher said "Line 23 to 32, use % 10 to check if there are 10 numbers printed on a row????????????????????? to replace the || expressions.??????????????????????"
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