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

Which methods of the AccountTester class use loops to validate the user\'s input

ID: 641568 • Letter: W

Question

Which methods of the AccountTester class use loops to validate the user's input? (Check all that apply.)

Question 20 options:

exerciseTransactions (line 45 of Listing 2).

exerciseTransactions (line 59 of Listing 2).

getUserValue (line 90 of Listing 2).

getUserCommand (line 114 of Listing 2).

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

exerciseTransactions (line 45 of Listing 2).

exerciseTransactions (line 59 of Listing 2).

getUserValue (line 90 of Listing 2).

getUserCommand (line 114 of Listing 2).

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 will helps you...

getUserValue (line 90 of Listing 2).

getUserCommand (line 114 of Listing 2).

getUserValue (line 90 of Listing 2).

getUserCommand (line 114 of Listing 2).

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote