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

Which statements are calling constructors to create new objects? (Check all that

ID: 641556 • Letter: W

Question

Which statements are calling constructors to create new objects? (Check all that apply.)

Question 3 options:

Line 8 of Listing 2.

Line 9 of Listing 2.

Line 19 of Listing 2.

Line 7 of Listing 3.

Listing 2 Below:

2
3 import java.util.Scanner;
4 import java.util.Random;
5
6 public class AccountTester
7 {
8 Random randomNumbers = new Random();
9 Scanner userInput = new Scanner(System.in);
10
11 public void testAccountClass()
12 {
13 System.out.println(" *** Testing the Account Class ***");
14
15 System.out.printf(" Current Interest Rate: %.2f%%", Account.CURRENT_RATE *
16 100.0);
17
18 System.out.println(" Creating Account Objects");
19 Account accountOne = new Account(5000.0);
20 Account accountTwo = new Account(accountOne);
21 accountOne.displayValues(" Initial Values for Account One:");
22 accountTwo.displayValues(" Initial Values for Account Two:");
23
24 System.out.println(" Exercising Account Transactions");
25 accountOne.credit(0.0);
26 accountOne.debit(-6);
27 accountTwo.credit(-1.50);
28 accountTwo.debit(100.0);
29 accountTwo.debit(5000);
30 exerciseTransactions(accountOne, 100, 500.0);
31 exerciseTransactions(accountTwo, 250.0);
32 accountOne.displayValues(" Updated Values for Account One:");
33 accountTwo.displayValues(" Updated Values for Account Two:");
34
35 System.out.println(" Exercising Future Value Calculators");
36 System.out.printf(" Calculation 1: $%.2f ", accountOne.futureValue(6.5,
37 0.05));
38 System.out.printf(" Calculation 2: $%.2f ", accountOne.futureValue(15,
39 0.05));
40 System.out.printf(" Calculation 3: $%.2f ", accountTwo.futureValue(6.5));
41 System.out.printf(" Calculation 4: $%.2f ", accountTwo.futureValue(15));
42 System.out.println(" *** Testing Complete *** ");
43 }
44
45 private void exerciseTransactions(Account thisAccount, int testCount,
46 double limit)
47 {
48 int count = 0;
49 while( count < testCount )
50 {
51 if( (count % 3) != 0 )
52 thisAccount.credit(getDataValue(limit));
53 else
54 thisAccount.debit(getDataValue(limit));
55 count++;
CSC-240 Java Programming

Line 8 of Listing 2.

Line 9 of Listing 2.

Line 19 of Listing 2.

Line 7 of Listing 3.

Listing 2 Below:

2
3 import java.util.Scanner;
4 import java.util.Random;
5
6 public class AccountTester
7 {
8 Random randomNumbers = new Random();
9 Scanner userInput = new Scanner(System.in);
10
11 public void testAccountClass()
12 {
13 System.out.println(" *** Testing the Account Class ***");
14
15 System.out.printf(" Current Interest Rate: %.2f%%", Account.CURRENT_RATE *
16 100.0);
17
18 System.out.println(" Creating Account Objects");
19 Account accountOne = new Account(5000.0);
20 Account accountTwo = new Account(accountOne);
21 accountOne.displayValues(" Initial Values for Account One:");
22 accountTwo.displayValues(" Initial Values for Account Two:");
23
24 System.out.println(" Exercising Account Transactions");
25 accountOne.credit(0.0);
26 accountOne.debit(-6);
27 accountTwo.credit(-1.50);
28 accountTwo.debit(100.0);
29 accountTwo.debit(5000);
30 exerciseTransactions(accountOne, 100, 500.0);
31 exerciseTransactions(accountTwo, 250.0);
32 accountOne.displayValues(" Updated Values for Account One:");
33 accountTwo.displayValues(" Updated Values for Account Two:");
34
35 System.out.println(" Exercising Future Value Calculators");
36 System.out.printf(" Calculation 1: $%.2f ", accountOne.futureValue(6.5,
37 0.05));
38 System.out.printf(" Calculation 2: $%.2f ", accountOne.futureValue(15,
39 0.05));
40 System.out.printf(" Calculation 3: $%.2f ", accountTwo.futureValue(6.5));
41 System.out.printf(" Calculation 4: $%.2f ", accountTwo.futureValue(15));
42 System.out.println(" *** Testing Complete *** ");
43 }
44
45 private void exerciseTransactions(Account thisAccount, int testCount,
46 double limit)
47 {
48 int count = 0;
49 while( count < testCount )
50 {
51 if( (count % 3) != 0 )
52 thisAccount.credit(getDataValue(limit));
53 else
54 thisAccount.debit(getDataValue(limit));
55 count++;
CSC-240 Java Programming

Explanation / Answer

hope it mayhelps you..

line numbers 19 and 20 arre creating new objects..