The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 3 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Which of the following identifiers used in the exerciseTransactions method defined at Line 45 of Listing 2 is an integer data type? (Check all that apply.)
Question 14 options:
| Â |
thisAccount |
| Â |
testCount |
| Â |
limit |
| Â |
count Listing 2: 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("\n\n*** Testing the Account Class ***"); 14 15 System.out.printf("\nCurrent Interest Rate: %.2f%%", Account.CURRENT_RATE * 16 100.0); 17 18 System.out.println("\n\nCreating Account Objects"); 19 Account accountOne = new Account(5000.0); 20 Account accountTwo = new Account(accountOne); 21 accountOne.displayValues("\nInitial Values for Account One:"); 22 accountTwo.displayValues("\nInitial Values for Account Two:"); 23 24 System.out.println("\n\nExercising 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("\n\nUpdated Values for Account One:"); 33 accountTwo.displayValues("\nUpdated Values for Account Two:"); 34 35 System.out.println("\n\nExercising Future Value Calculators"); 36 System.out.printf(" Calculation 1: $%.2f\n", accountOne.futureValue(6.5, 37 0.05)); 38 System.out.printf(" Calculation 2: $%.2f\n", accountOne.futureValue(15, 39 0.05)); 40 System.out.printf(" Calculation 3: $%.2f\n", accountTwo.futureValue(6.5)); 41 System.out.printf(" Calculation 4: $%.2f\n", accountTwo.futureValue(15)); 42 System.out.println("\n\n*** Testing Complete ***\n"); 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 A????1 Exam One Listings Page 4 of 6 56 } 57 } 58 59 private void exerciseTransactions(Account thisAccount, double limit) 60 { 61 char answer; 62 displayMenu(); 63 do 64 { 65 answer = getUserCommand(); 66 switch( answer ) 67 { 68 case 'D': 69 thisAccount.debit(getUserValue(limit)); 70 break; 71 case 'C': 72 thisAccount.credit(getUserValue(limit)); 73 break; 74 case 'V': 75 thisAccount.displayValues(); 76 break; 77 case 'M': 78 displayMenu(); 79 break; 80 } 81 } 82 while( answer != 'Q' ); 83 } 84 85 private double getDataValue(double maxValue) 86 { 87 return 1.0 + randomNumbers.nextDouble() * maxValue; 88 } 89 90 private double getUserValue(double limit) 91 { 92 double thisValue; 93 do 94 { 95 System.out.printf("Please enter a value (0.0 - %.2f): ", limit); 96 thisValue = userInput.nextDouble(); 97 if( !(thisValue >= 0.0 && thisValue <= limit) ) 98 System.out.printf("? Invalid input: %.2f\n", thisValue); 99 } 100 while( thisValue < 0.0 || thisValue > limit ); 101 return thisValue; 102 } 103 104 private void displayMenu() 105 { 106 System.out.println("\n\nPlease enter one of the following:"); 107 System.out.println(" D - to test the debit method"); 108 System.out.println(" C - to test the credit method"); 109 System.out.println(" V - to display the values of the Account"); 110 System.out.println(" M - to re-display this menu"); 111 System.out.println(" Q - to exit this test\n"); 112 }CSC-240 Java Programming A????1 Exam One Listings Page 5 of 6 113 114 private char getUserCommand() 115 { 116 char thisChar; 117 boolean goodChar; 118 do 119 { 120 System.out.print("Enter a command letter: "); 121 thisChar = userInput.next().toUpperCase().charAt(0); 122 goodChar = (thisChar == 'D' || thisChar == 'C' || thisChar == 'M' || 123 thisChar == 'Q' || thisChar == 'V'); 124 if( !goodChar ) 125 System.out.println("That is not a valid command letter"); 126 } 127 while( goodChar == false ); 128 return thisChar; 129 } 130Â Â Â } |
Â
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll