Recently I got major help from tutor but I forget some of the stuff he said and (unlike the next time tomorrow) I didn't have a recorder on me at the time so I can't go back and refer to what he was saying -_- .
I'd just like explanations to understand this.See even though my tutor graciously commented to the side what each line of code does I don't think I still know why what is there is there and how each statement works.
This is the nearly done code.
import java.util.Scanner; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ import java.util.Scanner; // brings in library to read keyboard input //import java.lang.String; public class Lab1 { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner usernum=new Scanner (System.in); //create object for keyboard input System.out.print("enter number of groups "); // ask user for a number int userInput = usernum.nextInt(); // takes keyboard input and put into variable userInput System.out.print("ASCII 1-127\n"); // print title for (int groups=0; groups<=127; groups=groups+1){ // loop until the counter is over userInput number String dec=Integer.toString(groups); //convert to dec String hex=Integer.toHexString(groups); //convert dec to hex char ascii=(char)groups; //convert dec to ascii System.out.print(dec+" "+hex+" "+ascii+" "); // print on screen if ((groups % userInput)==0) { System.out.print("\n"); } } System.out.print("\n"); } }
This is the nearly done code.What questions are left of this is a step that says that "each group of small columns will be 8 chars wide and properly aligned for values less than 6".What does that mean when you got something like this?.