Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(LO0) Declare one dimensional arrays to store: Students\' names for a class of 2

ID: 654375 • Letter: #

Question

(LO0) Declare one dimensional arrays to store:

Students' names for a class of 25 students

Students' scores for a class of 25 students

Students' letter grades for a class of 25 students

(LO0) Declare and initialize one dimensional arrays to store:

the days of the week

the different letter grades

the digits 0 to 9 (as numeric values)

(LO1) name the basic acivities (phases) that are involved in a software development process.

(LO1) Programming Language Levels (Generations)

(LO6) Types of errors

Suppose you want to represent each of the 50 states of the United States using a unique permutation of bits. How many bits would be needed to store each state representation?

Convert the decimal number 25 into binary:

Convert the binary number 101001 into decimal:

Convert the hexadecimal number A4B into octal:

GUI:

What is the difference between a Java application and a Java applet?

A Java application is a Java program that can stand on its own. It does not require a Web browser in order to execute.

A Java applet is aJava program that can be executed using a Web browser. Usually, the bytecode form of the Java applet is pulled across the Internet from another computer and executed locally.

Assuming you have a Graphics object called page, write a statement that will draw a square with a side length of 50, such that its upperleft corner is at point (16, 12).

page.drawRect(16, 12, 50, 50);

Assuming you have a Graphics object called page, write a sequence of statements that will draw a blue rectangle with a height of 20 and a width of 40, such that its upper-left corner is at point (30, 35).

page.setColor(Color.blue);

page.fillRect(30, 35, 40, 20);

What is the difference between a frame and a panel?

Both a frame and a panel are containers that can hold GUI elements. However, a frame is displayed as a separate window with a title bar, wjereas a panel cannot be displayed on its own. A panel is often displayed inside a frame.

Select the term from the following list that best matches each of the

following phrases:

container, content pane, frame, heavyweight, label, layout manager,

lightweight, panel

A component that is used to hold and organize other components.

A container displayed in its own window with a title bar.

Its primary role is to help organize other components in a GUI; it must be added to another container to be displayed.

This type of component is managed by the underlying operating system.

This type of component is managed by the Java program itself.

The part of a frame that displays visible elements.

A component that displays a line of text in a GUI.

Determines how the components in a container are arranged on the screen.

The term that best matches is

a. container    b. frame    c. panel    d. heavyweight

e. lightweight    f. content pane     g. label     h. layout manager

What type of event does a push button (a JButton object) generate?

A JButton object generates an action event when the button is ushed.

When that occurs, the actionPerformed method of the action listener associated with that button is invoked.

What are the general guidelines for GUI design?

know the needs and characteristics of the user

prevent user errors when possible

optimize user abilities by providing shortcuts and other redundant means to accomplish a task, and

be consistent in GUI layout and coloring schemes.

(LO3 & LO5) Write a method called swapString that takes a String as parameter. Swaps the first half of the string with the second half of the string and returns the new string. For example, if the parameter value is "ABCDE", it should return "CDEAB". Also, if the original string is "VALDOSTA", it should return "OSTAVALD"

(LO3 & LO5)Write a method named distance that accepts four integer arguments (x1, y1) and (x2,y2) coordinates for two points. Compute and return the distance between the two points using the following formula: Distance = sqrt ((x2-x1)^2 +(y2-y1)^2 )

(LO3 & LO5) Write a complete method named volume that accepts radius as a double single argument, computes and return the volume of the sphere. Use the formula:
Volume = 4/3 PI r^3

(LO3_LO4_LO5) Write a method named smallest that accepts a one dimensional array of type int, finds and returns the smallest value in the array.

(LO3 & LO5) Given the following UML diagram. Implement the DeliveryOrder class.
DeliveryOrder
-address: String
-phone: long
-cost: double

+DeliveryOrder (a:String, p:long, c:double)
+getAddress():String
+setPhone(pn:long):void
+toString():String


The toString returns address, phone, and cost with appropriate labels to be printed on three separate lines.

(LO3_LO4_LO5) Write a method named computeGrade that accepts a score of type int, computes and returns the corresponding grade.
Assume we use the standard grading system: A for scores 90-100, B for scores 80 and less than 90, etc.

(LO3_LO4_LO5) Write a method named populate that accepts a one dimensional array of type integer, assigns integer values in the range 10 to 50 (inclusive), and returns nothing.

(LO3 & LO5) Suppose that the Loan class is given as shown in the UML below. Write a test program that create a Loan object with loan amount 20000, annual interest rate is 5%, and number of years 15, and displays the monthly payment and total payment.

Loan

-annualInterestRate: double
-numberOfYear: int
-LoanAmount:double

+Loan()
+Loan(annualInterestRate:double, numberOfYears:int, LoanAmount: double)

.
.
.
+monthlyPayment():double
+totalPayment():double

(LO3_LO4_LO5) Write a method named rotateLeft that accetpts a one dimensional array of type int, rotates values one position left in the array. For example, if the original array has 1, 3, 5, 6. After the left rotation, the array should have 3, 5, 6, and 1.

(LO3_LO4_LO5) Given that we have the method rotateLeft (int [] list) is already implemented in the class. Write a another method named rotateLeftNTimes that accepts a one dimensional array of type int and times of type int. The method should rotate the list n times by making use of the rotateLeft method.

(LO3_LO4_LO5) Write a method called getList that takes in two int parameters low and high and returns an ArrayList containing all of the integers between low and high inclusive. For example, if the method is passed the parameters 4 and 7, it would return an ArrayList containing the integers 4, 5, 6, and 7.

(LO3_LO4_LO5) Write a method that takes in two int parameters low and high and returns an array containing all of the integers between low and high inclusive.

(LO3_LO4_LO5) Write a complete method countRange that accepts two int values m and n., where m is smaller than n. The method should add the values from m to n (inclusively) and return the sum. For example, if you invoke the method with countRange (5, 8), it should return 26 (sum of 5, 6, 7, and 8). Another example, if you invoke the method with countRange (5, 5), it should return 5.

(LO3_LO4_LO5) Write a method named max that accepts a Two-dimensional array of double values, finds and returns the largest value in the array.

(LO3_LO4_LO5) Write a method named getRandomValue that accepts a one-dimensional array of type double and returns an element from the array randomly.

(LO3_LO4_LO5) Write a method named printTable that accepts an argument of type int.
If argument passed is -20, it will print the following table:

X X+3        X-3
-20 -17          -23
-10   -7          -13
   0    3             -3
10 13             7
20 23          17

(LO3_LO4_LO5) Write a method named computeRowTotals that accepts a two dimensional array of type int. The method prints each row per line with its total. for example, if we had the following array:

10 5 20 30

30 5
4 6 1

The output may look like the following:
1. 10 5 20 30 65
2. 30 5 35
3. 4 6 1 11

(LO3_LO4_LO5) Write a method named printPattern that accepts an argument of type int that contains a single digit. If the argument is 5, the method displays the following pattern:

1 2 3 4 5
1 2 4 4
1 2 3
1 2
1

(LO3_LO4_LO5) Write a method called countEven that accepts two integer parameters

and returns the sum of the even values from the first to the second (inclusively) if the first is less than or equal the second, otherwise it returns 0.
For example, if you invoke the countRange (5, 10),
it should return 24 (sum of 6, 8, and 10);

(LO3_LO4_LO5) Write a method called countLetters that accepts a String parameter and returns the number of letters (upperCase or lowerCase) in the string.

(LO3_LO4_LO5) Write a method named readNamesAndScore that accepts a file argument (Scanner. input text file), one dimensional array of type String, and one dimensional array of type int. Read the names and store them in names array and scores in scores array. Assume the input file contains n <= 100 records. each record has a name and a score.
The method should stop if it reaches the end of file or if the array if full. The method should return the number of records read.

(LO3_LO4_LO5) Write a method named expand that accepts a one array of type integer. Doubles the size of the array and returns it.

(LO3_LO4_LO5) Write a method named isAlphabet that accepts a string argument and returns true if the received string contains only letters, otherwise, it return false.

(LO3_LO4_LO5) Write a method named isDigits that accepts a string argument and returns true if the string contains only digits, otherwise, it returns false.

(LO3_LO4_LO5) Write a method named tokens that accepts a line of text. It stores each token of the text into an entry in a string array. At the end, it returns the array. Hint: you may use the string splitt method.

(LO3_LO4_LO5) Write a method named encode that accepts a letter character, and returns next one. For example, if we pass "A', it returns 'B', if we pass 'M', it returns 'N, and if we pass 'Z', it returns 'A'. Assume all letters are uppercase.

(LO3_LO4_LO5) Write a method that accepts a single letter (uppercase) and returns the correcponding digit.

1

2 abc

3 def

4 ghi

5 jkl

6 mno

7 pqrs

8 tuv

9 wxyz

(LO4_LO6) What output is produced by the following code fragment?

int num = 87, max = 25;
if (num <= max * 2)
        System.out.println ("Apple");
System.out.println ("Orange");

(LO4_LO6) What output is produced by the following code fragment?

int num = 0, max = 13;
while (num < max){
        if ( num %5 == 0)
                        System.out.print (num + " " );
        num++;
}

(LO4_LO6) What output is produced by the following code fragment?

for (int i = 0; i < 7; i += 2)
        System.out.print (i + " ");

(LO4_LO6) What output is produced by the following code fragment?

int total = 10;
int max = 30;

total = (total > max) ? total + 1: total * 2;
System.out.println (total);

(LO4_LO6) What output is produced by the following code fragment?

int num = 10;
int max = 30;
while (num < max) {
        if (num == max/2){
                        num += 5;
        continue;
}
System.out.print(num + " ");
num += 5;
}

(LO4_LO6) What output is produced by the following code fragment?
ArrayList <String> names = new ArrayList <String>();
names.add ("Andy");
names.add ("Betty");
names.add (1, "Chet");
names.add (1, "Don");
names.remove(2);
System.out.println(names);

(LO4_LO6) What output is produced by the following code fragment?

int number = 10;
while (number > 0) {
        number = number - 2;
        if (number == 4)
                        break;
        System.out.print (number+" ");
}

(LO6) Trace the code below and write its output in the box.

public class FigureOut {

public static void main (String [] args) {
                int [] numbers = {10, 5, 100, 25, 50, 12};
                mystery1(numbers);
                mystery2(numbers);
}

public static void mystery1(int [] numbers) {
                int temp;
                for (int i = numbers.length -2; i >= 0; i--) {
                                for (int j= 0; j <= i; j++)
                                                if (numbers [j] < numbers [j+1]) {
                                                                temp = numbers [j];
                                                                numbers [j] = numbers [j+1];
                                                                numbers [j+1] = temp;
                                                }
                }
                numbers [0] = -9;
                numbers [numbers.length-1] = 99;
} // method mystery1

public static void mystery2 (int[] list) {
                for (int i = 0; i < list.length; i++)
                                System.out.print (list[i] + " ");
}

       } // class FigureOut

(LO6) Given the code below. What is the output?
        int n = 0;
        for (int i = 0; i < 10; i++)
                        for (int j = 15; j > 5; j--)
                                        for (int k = 0; k <= 5; k++)
                                                        for (int l =0; l < 5; l++)
                                                        n++;
        System.out.println (

1

2 abc

3 def

4 ghi

5 jkl

6 mno

7 pqrs

8 tuv

9 wxyz

Explanation / Answer

---->private final int size = 25;
private String [] names = new String [size];
private int [] scores = new int [size];
private String [] grades = new String [size];

Notes:
type varName = new type [size];
(valid java data)(Name of Array)(same valid java data)(specifies # of elements in array)

---->>private String [] days = new String [7];
private String [] grades = new String [5];
private int [] digits = new int [10];

--->>>Common methodologies for software development include waterfall, prototyping, iterative and incremental development, spiral development, rapid application development, extreme programming and agile methodology. Some people consider a life-cycle "model" a more general term for a category of methodologies and a software development "process" a more specific term to refer to a specific process chosen by a specific organization. For example, there are many specific software development processes that fit the spiral life-cycle model.

The waterfall model is a sequential development approach, in which development is seen as flowing steadily downwards (like a waterfall) through several phases, typically:

------>>>>>

Programming languages have been classified into several programming language generations. Historically, this classification was used to indicate increasing power of programming styles. Later writers have somewhat redefined the meanings as distinctions previously seen as important became less significant to current practice.

---->>>>>>>>

Types of error

There are three types of error: syntax errors, logical errors and run-time errors. (Logical errors are also called semantic errors).