Java Programming Requirements Programming Rules for this class: 1 - At the beginning of the file, the program must be documented, see program example below. 2 - Next enter all necessary import statements. 3 - Use camelCasing to name the class, methods, and variables. 4 - The Java class begins and ends in column 0. 5 - All global variables must declared and initialized at the beginning of the program, after naming the class. 6 - The methods begin and end in column 4. 7 - The main function must be the last method in the program. 8 - All other methods must be between the class beginning and the main method. 9 - The main method is for creating and initiallizing variables, calling methods, and ending the program. 10 - All pair of { } must be aligned in the same column for all programming sections, such as methods, if, while, for, etc. 11 - All paragraphs must be indented 4 (four) spaces from the previous outer section. 12 - Documment your program as much as possible. 13 - Leave two spaces between each method. Program example: /********************************************************************* Author : Your Name Course : Course Name and Times Professor : Michael Robinson Program : Program Name and Number Purpose : A brief description of the program Due Date : mm/dd/yyyy Certification: I hereby certify that this work is my own and none of it is the work of any other person. ..........{ your signature }.......... *********************************************************************/ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.*; public class JavaOne { //creating global variables //public means that these variables //can be accessed from any method in this program/class //static means that these variables were created in this program/class //creating a variable named gpa of data type double public static double gpa = 4.00; //creating a variable named credits of data type int public static int credits = 3; //creating a variable named globalCounter of data type int public static int globalCounter = 0; //creating a Single Dimension array named arrayName of data type String //dataType arrayName[] = { value1, value2, ..., valueN }; public static String className[] = { "Java", "Programming" }; //creating a Single Dimension array named numbers1 of data type int //containing 5 empty spaces public static int numbers1[] = new int [5] ; //creating a Single Dimension array named numbers2 of data type int //containing 5 values: 10, 20, 30, 40, 50 // at locations: 0 1 2 3 4 //the length of this array is 5, from 0 to 4 //dataType arrayName[] = { value1, value2, ..., valueN }; public static int numbers2[] = { 10, 20, 30, 40, 50 }; //creating a two Dimensions array named numbers2d of data type int //the size of this 2d array is 3 rows with 2 colums in each row //containing 6 empty indexes/locations //their addresses are: //numbers2d[0][0] //numbers2d[0][1] //numbers2d[1][0] //numbers2d[1][1] //numbers2d[2][0] //numbers2d[2][1] public static int numbers2d[][] = new int[3][2]; //creating a two Dimensions array named names of data type String //load 2D array, named names, with strings data types //the size of this 2d array is 3 rows with 2 colums in each row //containing 6 indexes/locations //names[0][0] data = Joe //names[0][1] data = Smith //names[1][0] data = Maria //names[1][1] data = Perez //names[2][0] data = James //names[2][1] data = Einstein public static String names[][] = { { "Joe", "Smith" }, { "Maria", "Perez" }, { "James", "Einstein" } }; public static void indentationSample() //creating and loading a 2 dim array of ints { //to show indentation System.out.printf( "%s\n", "Creating a 2 dimension Array" ); int x = 0; int y = 0; //declares a 10x10 two dimensional array int theArray[][] = new int[10][10]; int rows = 0; int cols = 0; for(x=0; x<10; x++) { for(y=0; y<10; y++) { theArray[x][y] = (x+y); System.out.printf( "[%2d] ", theArray[x][y] ); if( (x % 5) != 0 ) { rows += theArray[x][y]; } else if( (y % 5) == 0 ) { cols += theArray[x][y]; } } System.out.printf( "%s", "\n" ); } System.out.printf( "\n Total in rows = %d\n Total of cols = %d\n", rows, cols ); }//end of public static void indentationSample() //creating and loading a 2 dim array of ints public static void printTheData( double gpa, int credits, String className[], String myName, String myMajor ) { //printing all the data received, one field per line/row System.out.printf( "My name is %s\n", myName ); System.out.printf( "My major is %s\n", myMajor ); System.out.printf( "My gpa is %.2f\n", gpa ); System.out.printf( "My current class is %d credits\n", credits ); System.out.printf( "My Class name is %s \n\n", className[0] ); }//end of public static void printTheData( double gpa, int credits, String className[], String myName, String myMajor ) public static void main( String arg[] ) { //creating a String variable String myName = "Michael, Robinson"; //creating a String variable String myMajor = "IT, Cyber"; //calling a function named printTheData, passing 5 variables //three variable a global variables declared at the beginning of //this class, //and 2 are local variables declared in this this main method printTheData( gpa, credits, className, myName, myMajor ); //calling a function indentationSample(); }//end of public static void main( String arg[] ) }//end of public class JavaOne