New Semester
Started
Get
50% OFF
Study Help!
--h --m --s
Claim Now
Question Answers
Textbooks
Find textbooks, questions and answers
Oops, something went wrong!
Change your search query and then try again
S
Books
FREE
Study Help
Expert Questions
Accounting
General Management
Mathematics
Finance
Organizational Behaviour
Law
Physics
Operating System
Management Leadership
Sociology
Programming
Marketing
Database
Computer Network
Economics
Textbooks Solutions
Accounting
Managerial Accounting
Management Leadership
Cost Accounting
Statistics
Business Law
Corporate Finance
Finance
Economics
Auditing
Tutors
Online Tutors
Find a Tutor
Hire a Tutor
Become a Tutor
AI Tutor
AI Study Planner
NEW
Sell Books
Search
Search
Sign In
Register
study help
computer science
java software solutions
Java Software Solutions 9th Edition John Lewis, William Loftus - Solutions
PP 4.14 Write a JavaFX application that presents two buttons and a number (initially 50) to the user. Label the buttons Increment and Decrement. When the increment button is pushed, increment the displayed value. Likewise, decrement the value when the decrement button is pushed.
PP 4.15 Write a JavaFX application that presents an unlabeled text field in the center of the window surrounded by a circle. When the user enters a radius value in the text field and presses return, redraw the circle accordingly.
PP 4.16 Write a JavaFX application that presents four labeled text fields, allowing the user to enter values for name, age, favorite color, and hobby. Include a button labeled Print. When the button is pushed, the program should print the contents of all fields to the console window (standard
SR 5.1 What is meant by the flow of control through a program?
SR 5.2 What type of conditions are conditionals and loops based on?
SR 5.3 What are the equality operators? The relational operators? The logical operators?
SR 5.4 Given the following declarations, what is the value of each of the listed boolean expressions?
SR 5.5 What is a truth table?
SR 5.6 Assuming done is a boolean variable and value is an int variable, create a truth table for the expression: (value > 0) || !done
SR 5.7 Assuming c1 and c2 are boolean variables, create a truth table for the expression: (cl && !c2) || (!c1 && c2)
SR 5.8 What output is produced by the following code fragment given the assumptions below? if (numi
SR 5.9 How do block statements help us in the construction of conditionals?
SR 5.10 What is a nested if statement?
SR 5.11 For each assumption, what output is produced by the following code fragment? if (num1 >= num2) System.out.print (" red "); System.out.print(" orange "); if ((num1 +5) >= num2 System.out.print (" white "); else if ((num1 + 10) >= num2) System.out.print (" black ");
SR 5.12 Write an expression that will print a message based on the value of the int variable named temperature. If temperature is equal to or less than 50, it prints "It is cool." on one line and "Dress warmly." on the next. If temperature is greater than 80, it prints "It is warm." on one line and
SR 5.13 Why must we be careful when comparing floating point values for equality?
SR 5.14 How do we compare strings for equality?
SR 5.15 Write an equals method for the Die class of Section 4.2. The method should return true if the Die object it is invoked on has the same facevalue as the Die object passed as a parameter, otherwise it should return false.
SR 5.16 Assume the string variables 31 and 32 have been initialized. Write an expression that prints out the two strings on separate lines in lexicographic order.
SR 5.17 What is an infinite loop? Specifically, what causes it?
SR 5.18 What output is produced by the following code fragment? int low = 0, high = 10; while (low < high) System.out.println(low); low++;
SR 5.19 What output is produced by the following code fragment? int low = 10, high = 0; while (low
SR 5.20 What output is produced by the following code fragment? int low = 0, high = 10;
SR 5.21 What output is produced by the following code fragment? int low = 0, high = 10, mid; while (low
SR 5.22 Assume the int variable value has been initialized to a positive integer. Write a while loop that prints all of the positive divisors of value. For example, if value is 28, it prints divisors of 28: 1 2 4 7 14 28
SR 5.23 Assume the int variable value has been initialized to a positive integer. Write a while loop that prints all of the positive divisors of each number from one to value. For example, if value is 4, it prints divisors of 1: 1 divisors of 2: 12 divisors of 3: 13 divisors of 4: 124
SR 5.24 Devise statements that create each of the following Scanner objects. a. One for interactive input, which reads from System.in. b. One that reads from the file "info.dat". c. One that reads from the string variable infostring.
SR 5.25 Assume the scanner object filescan has been initialized to read from a file. Write a while loop that calculates the average number of characters per line of the file.
SR 5.26 What are the advantages of using an ArrayList object?
SR 5.27 What type of elements does an ArrayList hold?
SR 5.28 Write a declaration for a variable named dice that is an ArrayList of Die objects.
SR 5.29 What output is produced by the following code fragment? ArrayList names = new ArrayList (); names.add("Andy"); names.add("Betty"); names.add(1, "Chet"); names.add(1, "Don"); names.remove (2); System.out.println(names);
SR 5.30 How do you set up an event handler to process events from multiple sources?
SR 5.31 How can you determine which control generated an event?
SR 5.32 What are the two ways to create a Font object?
SR 5.33 What characteristics are represented by a Font object?
SR 5.34 What are some characteristics that affect how text is displayed but are not represented as part of a Font object?
SR 5.35 Which of the following could be determined using one or more check boxes? Explain. a. The condiments that should be put on a hamburger. b. Whether or not to collate a print job. c. Your favorite sport. d. All sports that you play. e. Your age range (0-12, 13-18, 19-29, 30-50, etc.)
SR 5.36 How do you determine if a particular check box is currently checked?
SR 5.37 How does an Box layout pane arrange its nodes? A VBox?
SR 5.38 Which of the following could be determined using a group of radio buttons? Explain. a. The condiments that should be put on a hamburger. b. Whether or not to collate a print job. c. Your favorite sport. d. All sports that you play. e. Your age range (0-12, 13-18, 19-29, 30-50, etc.)
SR 5.39 What is the primary difference between check boxes and radio buttons?
SR 5.40 How do you specify that a particular set of radio buttons work together to provide a set of mutually exclusive options?
EX 5.1 What happens in the MinOfThree program if two or more of the values are equal? If exactly two of the values are equal, does it matter whether the equal values are lower or higher than the third?
EX 5.2 What is wrong with the following code fragment? Rewrite it so that it produces correct output. if (total == MAX) if (total
EX 5.3 What is wrong with the following code fragment? Will this code compile if it is part of an otherwise valid program? Explain. if (length = MIN_LENGTH) System.out.println("The length is minimal.");
EX 5.4 What output is produced by the following code fragment?
EX 5.5 What output is produced by the following code fragment? int limit 100, numi = == 15, num2 = 40; if (limit
EX 5.6 Put the following list of strings in lexicographic order as if determined by the compareTo method of the string class. Consult the Unicode chart in Appendix C "fred" "Ethel" "2-2-2-3" "(([])}"
EX 5.7 What output is produced by the following code fragment? int num = 0, max = 20; while (num
EX 5.8 What output is produced by the following code fragment? = int num= 1, max 20;
EX 5.9 What is wrong with the following code fragment? What are three distinct ways it could be changed to remove the flaw? count = 50; while (count >= 0) System.out.println(count); count count + 1;
EX 5.10 Write a while loop that verifies that the user enters a positive integer value.
EX 5.11 Write a code fragment that reads and prints integer values entered by a user until a particular sentinel value (stored in SENTINEL) is entered. Do not print the sentinel value.
EX 5.12 Write a method called maxofTwo that accepts two integer parameters and returns the larger of the two.
EX 5.13 Write a method called larger that accepts two floating point parameters (of type double) and returns true if the first parameter is greater than the second, and false otherwise.
EX 5.14 Write a method called evenlyDivisible that accepts two integer parameters and returns true if the first parameter is evenly divisible by the second, or vice versa, and false otherwise. Return false if either parameter is zero.
EX 5.15 Write a method called isAlpha that accepts a character parameter and returns true if that character is either an uppercase or lowercase alphabetic letter.
EX 5.16 Write a method called floatEquals that accepts three floating point values as parameters. The method should return true if the first two parameters are equal within the tolerance of the third parameter.
EX 5.17 Write a method called isIsosceles that accepts three integer parameters that represent the lengths of the sides of a triangle. The method returns true if the triangle is isosceles but not equilateral (meaning that exactly two of the sides have an equal length), and false otherwise.
EX 5.18 Would it be better to use check boxes or radio buttons to determine the following? Explain. a. Your favorite book genre. b. Whether to make your profile visible or not. c. Which image format to use (jpg, png, or gif). d. Which programming languages you know.
PP 5.1 Write a program that reads an integer value from the user representing a year. The purpose of the program is to determine if the year is a leap year (and therefore has 29 days in February) in the Gregorian calendar. A year is a leap year if it is divisible by 4, unless it is also divisible
PP 5.2 Modify the solution to the previous project so that the user can evaluate multiple years. Allow the user to terminate the program using an appropriate sentinel value. Validate each input value to ensure it is greater than or equal to 1582.
PP 5.3 Write a program that determines and prints the number of odd, even, and zero digits in an integer value read from the keyboard.
PP 5.4 Write a program that plays the Hi-Lo guessing game with numbers. The program should pick a random number between 1 and 100 (inclusive), then repeatedly prompt the user to guess the number. On each guess, report to the user that he or she is correct or that the guess is high or low. Continue
PP 5.5 Create a modified version of the Palindrome Tester program so that the spaces, punctuation, and changes in uppercase and lowercase are not considered when determining whether a string is a palindrome. Hint: These issues can be handled in several ways. Think carefully about your design.
PP 5.6 Using the coin class defined in this chapter, design and implement a driver class called FlipRace whose main method creates two coin objects, then continually flips them both to see which coin first comes up heads three flips in a row. Continue flipping the coins until one of the coins wins
PP 5.7 Write a program that plays the Rock-Paper-Scissors game against the computer. When played between two people, each person picks one of three options (usually shown by a hand gesture) at the same time, and a winner is determined. In the game, Rock beats Scissors, Scissors beats Paper, and
PP 5.8 Design and implement an application that simulates a simple slot machine in which three numbers between 0 and 9 are randomly selected and printed side by side. Print an appropriate statement if all three of the numbers are the same, or if any two of the numbers are the same. Continue playing
PP 5.9 Modify the Die class from Chapter 4 so that the setFaceValue method does nothing if the parameter is outside of the valid range of values.
PP 5.10 Modify the Account class from Chapter 4 so that it performs validity checks on the deposit and withdraw operations. Specifically, don't allow the deposit of a negative number or a withdrawal that exceeds the current balance. Print appropriate error messages if these problems occur.
PP 5.11 Using the pairofDice class from PP 4.9, design and implement a class to play a game called Pig. In this game, the user competes against the computer. On each turn, the
PP 5.12 Design and implement a program to process golf scores. The scores of four golfers are stored in a text file. Each line represents one hole, and the file contains 18 lines. Each line contains five values: par for the hole followed by the number of strokes each golfer used on that hole. Store
PP 5.13 Design and implement a program that compares two text input files, line by line, for equality. Print any lines that are not equivalent.
PP 5.14 Design and implement a program that counts the number of integer values in a text input file. Produce a table listing the values you identify as integers from the input file.
PP 5.15 Design and implement a program that counts the number of punctuation marks in a text input file. Produce a
PP 5.16 Write a JavaFX application that allows the user to pick a set of pizza toppings using a set of check boxes. Assuming each topping cost 50 cents, and a plain pizza costs $10, display the cost of the pizza.
PP 5.17 Write a JavaFX application that allows the user to select a color out of five options provided by a set of radio buttons. Change the color of a displayed square accordingly.
PP 5.18 Write a JavaFX application that displays the drawing of a traffic light. Allow the user to select the state of the light (stop, caution, or go) from a set of radio buttons.
PP 5.19 Write a JavaFX application that allows the user to display the image of one of the Three Stooges (Moe, Larry, or Curly) based on a radio button choice.
PP 2.1 Create a revised version of the Lincoln program from Chapter 1 such that quotes appear around the quotation.
PP 2.2 Write a program that reads three integers and prints their average.
PP 2.3 Write a program that reads two floating point numbers and prints their sum, difference, and product.
PP 2.4 Write a program that prompts for and reads a person's name, age, college, and pet's name. Then print the following paragraph, inserting the appropriate data: Hello, my name is name and I am age years old. I'm enjoying my time at college, though I miss my pet petname very much!
PP 2.5 Create a version of the Temp Converter application to convert from Fahrenheit to Celsius. Read the Fahrenheit temperature from the user.
PP 2.6 Write a program that converts miles to kilometers. (One mile equals 1.60935 kilometers.) Read the miles value from the user as a floating point value.
PP 2.7 Write a program that prompts for and reads integer values for speed and distance traveled, then prints the time required for the trip as a floating point result.
PP 2.8 Write a program that reads values representing a time duration in hours, minutes, and seconds and then prints the
PP 2.9 Create a version of the previous project that reverses the computation. That is, read a value representing a number of seconds, then print the equivalent amount of time as a combination of hours, minutes, and seconds. (For example, 9999 seconds is equivalent to 2 hours, 46 minutes, and 39
PP 2.10 Write a program that determines the value of the coins in a jar and prints the total in dollars and cents. Read integer - values that represent the number of quarters, dimes, nickels, and pennies.
PP 2.11 Write a program that prompts for and reads a double value representing a monetary amount. Then determine the fewest number of each bill and coin needed to represent that amount, starting with the highest (assume that a ten-dollar bill is the maximum size needed). For example, if the value
PP 2.12 Write a program that prompts for and reads an integer representing the length of a square's side, then prints the square's perimeter and area.
PP 2.13 Write a program that prompts for and reads the numerator and denominator of a fraction as integers, then prints the decimal equivalent of the fraction.
EX 3.1 Write a statement that prints the number of characters in a string object called overview.
EX 3.2 Write a statement that prints the 8th character of a String object called introduction.
EX 3.3 Declare a string variable named str and initialize it to contain the same characters as a string object called name, except in all uppercase characters.
EX 3.4 Write a declaration for a string variable called change and initialize it to the characters stored in another string object called original with all 'e' characters changed to 'j'
EX 3.5 What output is produced by the following code fragment? String mi, m2, m3; m1 = "Quest for the Holy Grail"; = m2 mi.toLowerCase(); m3 mi +m2 System.out.println (m3.replace('g', 'z'));
EX 3.6 What is the effect of the following import statement? import java.awt.*;
EX 3.7 Assuming that a Random object has been created called generator, what is the range of the result of each of the - following expressions? a. generator.nextInt(20) b. generator.nextInt(8) + 1 C. generator.nextInt (12) + 2 d. generator.nextInt (35) + 10 e. generator.nextInt (100) 50
Showing 500 - 600
of 978
1
2
3
4
5
6
7
8
9
10
Step by Step Answers