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 “pro

computer science

Description

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. 

  • A sample run would be as follows.

    > java RelativelyPrimeArray 9
       1 2 3 4 5 6 7 8 9
    1    T T T T T T T T
    2 T    T F T F T F T
    3 T T    T T F T T F
    4 T F T    T F T F T
    5 T T T T    T T T T
    6 T F F F T    T F F
    7 T T T T T T    T T
    8 T F T F T F T    T
    9 T T F T T F T T

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.

  • A sample run would be as follows.

    > java Distribution100 15 5 82 2 1 74 19 47 64 39 77 25 99 100 1 10
    9 numbers entered are less than or equal to 50.
    6 numbers entered are greater than 50.

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). 

    • A sample run would be as follows.
> java Average 4
Joe 3 5 2
Tim 4 1 5
Jane 6 3 2
Jack 8 3 5
Jill 5 4 9
Mike 6 7 3
<Ctrl-D> 

Joe 3 5 2 3.33
Tim 4 1 5 3.33
Jane 6 3 2 3.67
Jack 8 3 5 5.33


Related Questions in computer science category


Disclaimer
The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.