2.99 See Answer

Question: Write an application that allows a user


Write an application that allows a user to select a country from a list box that contains at least seven options. After the user makes a selection, display the country’s capital city. Save the file as JCapitals.java.


> Create a Card class so that each Card holds the name of a suit (Spades, Hearts, Diamonds, or Clubs) as well as a value (Ace, King, Queen, Jack, or a number value). Save the file as Card.java. b. Create an array of 52 Card objects, assigning a different v

> Create a Die class whose constructor sets a value from 1 to 6. Include a method to return the value. Save the file as Die.java. Create an application that randomly “throws” five dice for the computer and five dice for

> Write an application that contains an array of 10 multiple-choice quiz questions related to your favorite hobby. Each question contains three answer choices. Also create an array that holds the correct answer to each question—A, B, or C. Display each que

> Eliza is a famous 1966 computer program written by Joseph Weizenbaum. It imitates a psychologist (more specifically, a Rogerian therapist) by rephrasing many of a patient’s statements as questions and posing them to the patient. This type of therapy (som

> Create a simple guessing game, similar to Hangman, in which the user guesses letters and then attempts to guess a partially hidden phrase. Display a phrase in which some of the letters are replaced by asterisks: for example, G* T*** (for Go Team). Each t

> Create a Rock Paper Scissors game in which the user enters a string rock, paper, or scissors. Allow the choice to be valid whether the player enters a choice in uppercase letters, lowercase letters, or a combination of the two. To allow for player misspe

> Design a Card class. The class holds fields that contain a Card’s value and a suit that is one of the four strings Spades, Hearts, Diamonds, or Clubs. Also, add a field to the class to hold the String representation of a Cardâ&#12

> Two people play the game of Count 21 by taking turns entering a 1, 2, or 3, which is added to a running total. The player who adds the value that makes the total reach or exceed 21 loses the game. Create a game of Count 21 in which a player competes agai

> a. Yummy Catering provides meals for parties and special events. In Chapter 4, you created an Event class for the company. Now, make the following changes to the class: ❯❯ Currently, the class contains a constant for the price per guest ($35) that is use

> a. Create a Die class from which you can instantiate an object containing a random value from 1 through 6. The constructor sets the value. Include a method to return the value. Save the file as Die.java. b. Use the Die class to create a simple dice game

> Many games use coin tosses, particularly to determine events such as which player takes the first turn in a game. When you toss one coin, the probability of getting “heads” is 50 percent. When you toss two coins, the probability of getting exactly one “h

> Create a game that generates a random number from 1 to 10. Include a loop that continually prompts the user for the number, indicating whether the guess is high or low, until the user enters the correct value. After the user correctly guesses the number,

> Write an application that creates a quiz. The quiz should contain at least five questions about a hobby, popular music, astronomy, or any other personal interest. Each question should be a multiple-choice question with at least four answer options. When

> In the game Rock Paper Scissors, two players simultaneously choose one of three options: rock, paper, or scissors. If both players choose the same option, then the result is a tie. However, if they choose differently, the winner is determined as follows:

> Each of the following files in the Chapter08 folder of your downloadable student files has syntax and/or logic errors. In each case, determine the problem and fix the program. After you correct the errors, save each file using the same filename preceded

> Each of the following files in the Chapter07 folder of your downloadable student files has syntax and/or logic errors. In each case, determine the problem and fix the application. After you correct the errors, save each file using the same filename prece

> Each of the following files in the Chapter06 folder of your downloadable student files has syntax and/or logic errors. In each case, determine the problem and fix the program. After you correct the errors, save each file using the same filename preceded

> Each of the following files in the Chapter05 folder of your downloadable student files has syntax and/or logic errors. In each case, determine the problem and fix the program. After you correct the errors, save each file using the same filename preceded

> Each of the following files in the Chapter14 folder of your downloadable student files has syntax and/or logic errors. In each case, determine the problem and fix the program. After you correct the errors, save each file using the same filename preceded

> In previous chapters, you have created a number of programs for Sunshine Seashore Supplies. Now, create an interactive GUI program that allows the user to enter a rental time in hours into a text field; if the value entered is not numeric, set the rental

> Each of the following files in the Chapter13 folder of your downloadable student files has syntax and/or logic errors. In each case, determine the problem and fix the program. After you correct the errors, save each file using the same filename preceded

> Each of the following files in the Chapter12 folder of your downloadable student files has syntax and/or logic errors. In each case, determine the problem and fix the errors. After you correct the errors, save each file using the same filename preceded w

> Each of the following files in the Chapter11 folder of your downloadable student files has syntax and/or logic errors. In each case, determine the problem and fix the program. After you correct the errors, save each file using the same filename preceded

> Each of the following files in the Chapter10 folder of your downloadable student files has syntax and/or logic errors. In each case, determine the problem and fix the program. After you correct the errors, save each file using the same filename preceded

> Each of the following files in the Chapter09 folder of your downloadable student files has syntax and/or logic errors. In each case, determine the problem and fix the program. After you correct the errors, save each file using the same filename preceded

> Write a program for Horizon Phones, a provider of cellular phone service. Prompt a user for maximum monthly values for talk minutes needed, text messages needed, and gigabytes of data needed, and then display a recommendation for the best plan for the c

> Write an application for the Shady Rest Hotel; the program determines the price of a room. Ask the user to choose 1 for a queen bed, 2 for a king, or 3 for a king and a pullout couch. The output echoes the input and displays the price of the room: $125 f

> Write an application that asks a user to enter three integers. Display them in ascending and descending order. Save the file as AscendingAndDescending.java.

> Write an application that asks a user to enter an integer. Pass the integer to a method that determines whether the number is even and returns a Boolean value. Display a statement that indicates whether the integer is even or odd. Save the file as EvenOd

> Write an application that prompts the user for a single-digit integer and uses a loop to create the pattern shown in the example in Figure 6-32. In the example, the user entered a 3, and 10 lines are displayed; each 3 appears one additional space to the

> In previous chapters, you have created a number of programs for Yummy Catering. Now, create an interactive GUI program that allows the user to enter the number of guests for an event into a text field; if the value entered is not numeric, set the event p

> Write an application that displays every perfect number from 1 through a user-supplied limit. A perfect number is one that equals the sum of all the numbers that divide evenly into it. For example, 6 is perfect because 1, 2, and 3 divide evenly into it,

> Write an application that prompts a user for two integers and displays every integer between them. Display a message if there are no integers between the entered values. Make sure the program works regardless of which entered value is larger. Save the fi

> Write an application that displays the factorial for every integer value from 1 to a user-entered limit. A factorial of a number is the product of that number multiplied by each positive integer lower than it. For example, 4 factorial is 4 * 3 * 2 * 1, o

> Write an application that asks a user to type an even number or the sentinel value 999 to stop. When the user types an even number, display the message Good job! and then ask for another input. When the user types an odd number, display an error message

> Write an application that prompts a user for the number of years the user has until retirement and the amount of money the user can save annually. If the user enters 0 or a negative number for either value, reprompt the user until valid entries are made.

> Write an application that includes final constants named START and STOP that are set to 5 and 500, respectively. The application counts by five from 5 through 500 inclusive, and it starts a new line after every multiple of 50 (50, 100, 150, and so on). S

> Create a class named Purchase. Each Purchase contains an invoice number, amount of sale, and amount of sales tax. Include set methods for the invoice number and sale amount. Within the set method for the sale amount, calculate the sales tax as 5 percent

> The Huntington High School basketball team has five players named Ali, Bob, Cai, Dan, and Eli. Accept the number of points scored by each player in a game, and create a bar chart that illustrates the points scored by displaying an asterisk for each point

> Assume that the population of Mexico is 128 million and the population of the United States is 323 million. Accept two values from a user: an assumption of an annual increase in the population of Mexico and an assumption for an annual decrease in the U.S

> Use the Web to locate the lyrics to the traditional song “The Twelve Days of Christmas.” The song contains a list of gifts received for the holiday. The list is cumulative so that as each “day” passes, a new verse contains all the words of the previous v

> In previous chapters, you have created a Rental class for Sunshine Seashore Supplies. The class contains a default constructor as well as an overloaded version that requires a contract number (a letter followed by three digits), a time for the rental (in

> Create a class named Apartment that holds an apartment number, number of bedrooms, number of baths, and rent amount. Create a constructor that accepts values for each data field. Also create a get method for each field. Write an application that creates

> Create an Automobile class for a dealership. Include fields for an ID number, make, model, color, year, and miles per gallon. Include get and set methods for each field. Do not allow the ID to be negative or more than 9999; if it is, set the ID to 0. Do

> Create a class named JobApplicant that holds data about a job applicant. Include a name, a phone number, and four Boolean fields that represent whether the applicant is skilled in each of the following areas: word processing, spreadsheets, databases, and

> Acme Parts runs a small factory and employs workers who are paid one of three hourly rates depending on their shift: first shift, $17 per hour; second shift, $18.50 per hour; third shift, $22 per hour. Each factory worker might work any number of hours p

> Write an application that uses the LocalDate class to access the current date. Prompt a user for a month, day, and year. Display a message that specifies whether the entered date is (1) not this year, (2) in an earlier month this year, (3) in a later

> Search the Internet for information about how to use a JTextArea, its constructors, and its setText() and append() methods. Write an application that allows the user to select options for a dormitory room. Use JCheckBoxes for options such as private room

> Write an application that allows the user to choose insurance options in JCheckBoxes. Use a ButtonGroup to allow the user to select only one of two insurance types—HMO (health maintenance organization) or PPO (preferred provider organization). Use regula

> Design an application for the Sublime Sandwich Shop. The user makes sandwich order choices from list boxes, and the application displays the price. The user can choose from three main sandwich ingredients of your choice (for example, chicken) at three di

> Write an application that allows a user to select one of at least five television shows to watch on demand. When the user selects a show, display a brief synopsis. Save the file as JTVDownload.java. b. Change the JTVDownload application to include an edi

> In previous chapters, you have created an Event class for Yummy Catering. The class contains a default constructor as well as an overloaded constructor that requires an event number (a letter followed by three digits) and a number of guests attending the

> Write an application for Lambert’s Vacation Rentals. Use separate ButtonGroups to allow a client to select one of three locations, the number of bedrooms, and whether meals are included in the rental. Assume that the locations are parkside for $600 per w

> Create an application with a JFrame and at least six labels that contain facts about your favorite topic—for example, the French Revolution or astronomy. Every time the user clicks a JButton, remove one of the labels and add a different one. Save the fil

> Write an application that instantiates a JFrame that contains a JButton. Disable the JButton after the user clicks it. Save the file as JFrameDisableButton.java. b. Modify the JFrameDisableButton program so that the JButton is not disabled until the user

> Create an application for Paula’s Portraits, a photography studio. The application allows users to compute the price of a photography session. Paula’s base price is $40 for an in-studio photo session with one person. The in-studio fee is $75 for a sessio

> Write an application that displays a JFrame containing the opening sentence or two from your favorite book. Save the file as JBookQuote.java. b. Add a button to the frame in the JBookQuote program. When the user clicks the button, display the title of th

> Write a program that prompts a user for two Strings and two integers. Send the two Strings to a generic method that sends them to another method to display, swaps their values, and then sends them to the display method again. Then send the two integers t

> Roberto has purchased buildings that contain apartments to rent. Create an Apartment class that contains fields for the street address, apartment number, monthly rent amount, and number of bedrooms for each Apartment that he owns. Include a constructor t

> Write a program that creates two ArrayLists—one to hold Strings and one to hold Integers. Prompt the user for a word, and while the user does not enter a sentinel value, continue to add each entered word to the ArrayList, sort the list, pass the list to

> Write a program that creates a String ArrayList. Continually prompt the user for Strings to add to the list until a sentinel value is entered. Use an iterator to display all the Strings, then continually ask the user for a String to eliminate until a sen

> Write a program that creates a String ArrayList. Continually prompt the user for Strings to add to the list until the user enters a sentinel value. Display the Strings in a single line separated by commas and ending with a period. Save the file as CommaP

> Sunshine Seashore Supplies rents beach equipment to tourists. In previous chapters, you developed a Rental class that holds equipment rental information, including a contract number and hours and minutes for each Rental. Now write an application that cre

> Write a program that creates an Integer ArrayList and store at least four integers in it. Use an iterator to display all the numbers. Then prompt the user for a value to remove from the list. If the number appears in the list, remove it. Display the list

> Create a Purchase class similar to the one described in a “You Do It” section earlier in this chapter. The Purchase class contains a String category for the purchase (such as groceries) and a numeric price. Include a c

> Loris Manufacturing makes 1,000 products per month and has been increasing production at a rate of 6 percent each month. Write a program that accepts a production goal from the user. If the entered goal is less than 1,000, display a message that indicate

> Assume that the current population of California is 39 million and that the population of Texas is 28 million. The population of Texas appears to be growing at a faster rate than that of California. Write an application that accepts values for the projec

> The Fibonacci sequence is the series of numbers 1, 1, 2, 3, 5, 8, 13, 21, and so on. The last number in the Fibonacci sequence is always the sum of the preceding two numbers. For example, 13 is the sum of 5 and 8, and 21 is the sum of 8 and 13. The seque

> Figure 12-27 shows two typical executions of a program that displays a large V on the screen after the user enters a height. Write a program that passes the following values to a recursive method that produces the V: the current line number, the number o

> Figure 12-26 shows two typical executions of a program that displays a triangle. Create this program by prompting the user for a number of lines to display. The first row of the output contains the number of spaces that equals the number of lines that wi

> Figure 12-20 earlier in this chapter shows the output of a program that displays any number of Os running diagonally from top left to bottom right. Now, write a program that prompts the user for a number of lines to display, and then use a recursive meth

> Write a program that creates an array of at least 20 integers and do the following: ❯ Prompt the user for a starting position, and continually reprompt the user for a new value if the starting position is less than 0 or greater than the highest allowed s

> Write a program that prompts the user for two integers. Pass them to a recursive method that returns the product of the two integers without using multiplication. In other words, instead of using the multiplication operator, write the method using the kn

> Yummy Catering provides meals for parties. In previous chapters, you have created an Event class that holds details for scheduled events, including an event number and number of guests. Now write an application that creates an array of five Event objects

> Write a program that prompts the user for an integer. Pass the integer to a method that determines whether the number is greater than 0; if it is, the method displays the number and passes one less than the parameter value to a second method. The second

> Write a program that prompts a user for two integers and then sums all the values between and including the two integers. Ensure that the second integer entered is larger than the first by continuing to reprompt the user until it is. Then pass the two in

> Write a program that allows you to create a file of customers for a company. The first part of the program should create an empty file suitable for writing a three-digit ID number, six-character last name, and five-digit zip code for each customer. The s

> The Rochester Bank maintains customer records in a random access file. Write an application that creates 10,000 blank records and then allows the user to enter customer account information, including an account number that is 9998 or less, a last name, a

> Create an application that allows you to enter student data that consists of an ID number, first name, last name, and grade point average. Depending on whether the student’s grade point average is at least 2.0, output each record either to a file of stud

> Write an application that allows a user to enter a filename and an integer representing a file position. Assume that the file is in the same folder as your executing program. Access the requested position within the file, and display the next 10 characte

> Using a text editor, create a file that contains a list of at least 15 six-digit account numbers. Write a program that reads in each account number in the file, and display whether the account number is valid. An account number is valid only if the last

> Create a program that allows a user to input customer records (ID number, first name, last name, and balance owed) and save each record to a file. Save the program as WriteCustomerList.java. When you execute the program, be sure to enter multiple records

> Write an application that determines which, if any, of the following files are stored in the folder where you have saved the exercises created in this chapter: autoexec.bat, CompareFolders.java, FileStatistics.class, and Hello.doc. Save the file as FindS

> Create a file that contains a line of your favorite song lyric. Use a text editor such as Notepad, and save the file. Copy the file contents, and paste them into a word-processing program such as Word. Write an application that prompts the user for the n

> Throughout the Case Problems in this course, you have been using a Rental class that obtains all the data for rentals from Sunshine Seashore Supplies, including details about the contract number, length of the rental, and equipment type. Now, create an a

> Yummy Catering provides meals for parties and special events. In previous chapters, you have developed an Event class that holds catering event information. Now modify the Event class as follows: ❯❯ Modify the method that sets the event number in the Eve

> The 1-year spot rate is 2 percent, the 2-year spot rate is 3 percent, the 3-spot rate is 4 percent, and the 4-year spot rate is 5 percent. a. How many forward rates are there over the four-year period? Identify each for- ward rate with the symbol tft1n w

> A three-year, 4 percent government bond is trading at $1,001. The spot yield curve indicates that the 1-year spot rate is 2 percent, the 2-year spot rate is 3 percent, and the 3-year spot rate is 4 percent. Is there an arbitrage opportunity, that is, is

> Suppose Snowmobile Inc. is considering whether or not to launch a new snowmobile. It expects to sell the vehicle for $10,000 over five years at a rate of 100 per year. The variable costs of making one unit are $5,000, and the fixed costs are expected to

> The market portfolio has an expected return of 11 percent with a 25 percent volatility. The risk-free rate is 5 percent. a. Investor A with $180,000 has a target expected return of 9 percent. How should he invest his $180,000? b. What are the volatility

> a. You hold an efficient portfolio. Which of the CML or the SML gives you the expected return on your portfolio? What could its composition be? b. You hold an inefficient portfolio. Which of the CML or the SML gives you the expected return on your portf

> Alvinstar Co. is considering investing in a new animal feed project. The product will be a soup for cats to be sold in cans. Alvinstar plans to sell 100,000 cans a year for four years at a price of $4 per can. Fixed costs will include rent on the product

> Astra Co. is considering introducing a bonus system based on economic value added (EVA) and has short-listed two bonus equations. The first one would simply compute the bonus as a percentage of EVA, such that: Bonus = x percent of EVA 5 x% 3 EVA (1) The

> Fiona Berling’s division of Mcsystems generates a net operating profit after tax, or NOPAT, of $1 million on an invested capital base of $1 million. The weighted average cost of capital of Ms Berling’s division is 20 percent. The division has been asked

> Below are the last three years’ financial statements of Sentec Inc., a distributor of electrical fixtures. a. Compute Sentec’s working capital requirement (WCR) on December 31, Year 1, Year 2, and Year 3. b. Prepare Se

> Suppose there are no government zero-coupon bonds. If investors demand default- free zeros, outline the process that would create these zeros using government coupon-paying bonds. Illustrate the method with the case of a four-year, 5 percent government z

> Equation 18.7 shows that market value added (MVA) of an investment project is the present value of the stream of the future economic value added (EVA) of the project. Because a firm can be viewed as a basket of investment projects, the MVA of a firm is s

> The Southern Communication Corporation (SCC) has $1 billion of capital invested in several telecommunication projects that are expected to generate a pre-tax operating profit of $170 million next year. SCC has an estimated pre-tax cost of capital of 15 p

> You want to test the speed with which stock market prices adjust to positive earnings’ announcements. Company A makes its earnings announcement on May 20 and Company B on June 16. You collected for each company daily share price returns

> The market portfolio has an expected return of 9 percent with a 10 percent volatility. The risk-free rate is 4 percent. A stock has a 20 percent volatility and a correlation coefficient of minus 0.10 with the market. a. What is the stock’s beta? What doe

2.99

See Answer