Following the instructions given in the textbook and the accompanying website on how to compile and run Java programs, write three programs named as required (see below), for this assignment, there will be three attachments. Each attached file will be a java program with a file name of “program name.java.”
1. Write a well-documented (commented) program, “RelativelyPrimeArray,” that takes an integer command-line argument “n” and creates an (n+1)-by-(n+1) Boolean array “rpa” such that rpa[i][j] (for i,j>0) is true if i and j are relatively prime (have no common factors), and is false otherwise. It should then output as is shown by the sample run below. If the indexes i,j (for i,j>0) are equal, it should output a single space. If the indexes are not equal, then it should output a "T" character if the array element specified by the indexes is true or an "F" character if it is false.
2. Write a well-documented (commented) program, “Distribution100,” that takes integer command-line arguments. The first argument would be the count of the remaining arguments that are between 1 and 100 (inclusive of 1 and 100). It then prints out the count of numbers entered that are less than or equal to 50 and the count of numbers that are greater than 50 from those remaining arguments.
3. Write a well-documented (commented) program, “Average,” that reads in lines from standard input with each line containing a name and three integers and then uses “printf()” to print a table with a column of the names, the integers, and the average of the three integers accurate to two decimal places. The user will specify the number of names as a command-line argument and then type in at least that number of names (along with three integers for each name). He would signal the end of input by pressing Control D (or Control Z and then Enter on Windows).
Get Free Quote!
441 Experts Online