Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 4.5, Problem 4.5.1CP
If you run Listing 4.3 GuessBirthday.java with input 1 for Set1, Set3, and Set4 and 0 for Set2 and Set5, what will be the birthday?
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
You will implement a variant of the number guessing game we played in lecture. In this variant, you will ask the user to
guess the price of a $42,500 car. Let's assume that the player knows the price of the car is rounded to the nearest
$500. If a player's guess is not exactly correct, your program will tell them they are either too high or too low. The
player will get as many guesses as they need to guess the price of the $42,500 car. They need to guess correctly to
finish the game, but they will only win the game if they used 5 or fewer guesses.
Here are two examples of how the program should work for both cases:
Guess the price and win the prize!
Enter your guess:50000
Too high!
Enter your guess:40000
Too low!
Enter your guess:45000
Too high!
Enter your guess: 42500
You won the car!
Guess the price and win the prize!
Enter your guess:46000
Too high!
Enter your guess:45000
Too high!
Enter your guess: 44000
Too high!
Enter your guess: 43000
Too high!
Enter your guess:4
Too low!
:…
Java
Don't use Math.pow and the programming language is Java.
Chapter 4 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 4.2 - Evalute the following method calls: (a)...Ch. 4.2 - True or false? The argument for trigonometric...Ch. 4.2 - Write a statement that converts 47 degrees to...Ch. 4.2 - Write a statement that converts PI to an angle in...Ch. 4.2 - Write an expression that obtains a random integer...Ch. 4.2 - Prob. 4.2.6CPCh. 4.2 - Prob. 4.2.7CPCh. 4.3 - Use print statements to find out the ASCII code...Ch. 4.3 - Which of the following are correct literals for...Ch. 4.3 - How do you display the characters \ and "?
Ch. 4.3 - Evaluate the following: Int i = '1'; int j ='1' +...Ch. 4.3 - Can the following conversions involving casting be...Ch. 4.3 - Show the output of the following program: public...Ch. 4.3 - Write the code that generates a random lowercase...Ch. 4.3 - Show the output of the following statements:...Ch. 4.4 - Suppose s1, s2, and s3 are three strings, given as...Ch. 4.4 - Prob. 4.4.2CPCh. 4.4 - Show the output of the following statements (write...Ch. 4.4 - Prob. 4.4.4CPCh. 4.4 - Let s1 be " Welcome " and s2 be " welcome ". Write...Ch. 4.4 - Write one statement to return the number of digits...Ch. 4.4 - Write one statement to return the number of digits...Ch. 4.5 - If you run Listing 4.3 GuessBirthday.java with...Ch. 4.5 - If you enter a lowercase letter such as b, the...Ch. 4.5 - What would be wrong if lines 6 and 7 are in...Ch. 4.6 - Prob. 4.6.1CPCh. 4.6 - Prob. 4.6.2CPCh. 4.6 - Show the output of the following statements: (a)...Ch. 4 - (Geometry: area of a pentagon) Write a program...Ch. 4 - (Geometry: great circle distance) The great circle...Ch. 4 - (Geography: estimate areas) Use the GPS locations...Ch. 4 - (Geometry: area of a hexagon) The area of a...Ch. 4 - (Geometry: area of a regular polygon) A regular...Ch. 4 - (Random points on a circle) Write a program that...Ch. 4 - (Corner point coordinates) Suppose a pentagon is...Ch. 4 - (Find the character of an ASCII code) Write a...Ch. 4 - (Find the Unicode of a character) Write a program...Ch. 4 - (Guess birthday) Rewrite Listing 4.3,...Ch. 4 - (Decimal to hex) Write a program that prompts the...Ch. 4 - (Hex to binary) Write a program that prompts the...Ch. 4 - (Vowel or consonant?) Write a program that prompts...Ch. 4 - (Convert Letter grade to number) Write a program...Ch. 4 - (Phone key pads) The international standard...Ch. 4 - (Random character) Write a program that displays a...Ch. 4 - (Days of a month) Write a program that prompts the...Ch. 4 - (Student major and status) Write a program that...Ch. 4 - (Business: check ISBN-10) Rewrite Programming...Ch. 4 - (Process a string) Write a program that prompts...Ch. 4 - (Check SSN) Write a program that prompts the user...Ch. 4 - (Check substring) Write a program that prompts the...Ch. 4 - 23 (Financial application: payroll) Write a...Ch. 4 - (Order three cities) Write a program that prompts...Ch. 4 - (Generate vehicle plate numbers) Assume that a...Ch. 4 - (Financial application: monetary units) Rewrite...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
The _______ member function returns a files current read position.
Starting Out with C++: Early Objects (9th Edition)
16. In a simple electric circuit, the current (I) must remain below 40 milliarr.ps (I < 40 mA) and must also sa...
Thinking Like an Engineer: An Active Learning Approach (4th Edition)
In Exercises 39 through 44, write a program to carry out the stated task. Cost of Electricity The cost of the e...
Introduction To Programming Using Visual Basic (11th Edition)
(Temperature Conversions) Implement the following integer methods: Method celsius returns the Celsius equivalen...
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
What are the design issues for character string types?
Concepts Of Programming Languages
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- In JAVA, Write a program to find the sum of all numbers divisible by 5 in the range 1 to 100.arrow_forwardWrite a Java Program In this problem, you will create a small guessing game, where the user tries to guess the order in which the letters of a word will be randomized. To do so: 1. Prompt the user to select one of two levels. If the user selects easy, the game will generate a random word of five characters. If the user selects hard, the game will generate a random word of ten characters. 2. Generate a random word, of unique characters, based on the level selected by the user. Print the generated word. 3. Randomly shuffle the letters of the word and ask the user to enter a word guessing the new order of the letters. 4. Print the randomly shuffled word and the result which is the similarity percentage between the answer and the shuffled word. 5. Keep track of the scores of the user in a text file called “Scores.txt”. The document will show the scores as shown in the sample below. Each time the user finishes a game add the score to the document. Manually create the document with the…arrow_forwardHello, I am using the Intro to Java programmming and data structures by Y. Daniel Liang. Our professor wants us to generate a random number in java between 1 and 100. Then prompt the user for a number between 1 and 4. Next, the program will determine if the number entered by the user is a factor of the random number. I feel like I have some parts of the code down pack but not all of it. Thus far I have: import java.util.Scanner;public class Module_Project3 { public static void main(String[] args) {Scanner input = new Scanner(System.in);int num1 = (int)(Math.random()*100+1);int num2 = (int)(Math.random()*100+1);int num3 = (int)(Math.random()*100+1);int num4 = (int)(Math.random()*100+1);arrow_forward
- This is for java, I need the code in java format for programs like eclipesarrow_forwardyou are asked to test the log10 function (double log10(double a)) in Java Math library. You do not have the source code for the function however the specifications of the function are available. The specifications of the function as follows: Function returns the base 10 logarithm of the given double value. If the argument is equal to 10n for integer n, then the result is n. If the argument is NaN or less than zero, then the result is NaN. If the argument is positive infinity, then the result is positive infinity. If the argument is positive zero or negative zero, then the result is negative infinity. *NaN is a numeric data type value which stands for “not a number” (e.g. Double.NaN) 1. Explain why performing exhaustive testing (testing with all possible inputs) on this method might not be considered efficient testing and propose an efficient testing strategy. 2. Explain how the proposed testing strategy is performed and list the minimum amount of test inputs required to…arrow_forwardIn JAVA language: Write a program to print the sum of all numbers which are divisible by 5 in the range 1 to 500.arrow_forward
- HangmanAA.java For this program, you will create the game Hangman. (If you are unsure of how to play Hangman, Google it.) The game will start by asking player 1 for a word or phrase (can be multiple words). Then player 1 will be asked how many missed guesses are allowed by player 2. Once this information is received, player 2 will take over. (Have the program print many blank lines of space so that player 2 can’t see what player 1 entered.) The instructions should be displayed for player 2 as well as the number of misses they’re allowed to make before they lose the game. The screen should also output dashes or underscores to represent each letter of player 1’s secret word/phrase. Player 2 should guess one letter at a time. Case should not matter. Typing x or X should give the same result. If that letter is present in the mystery phrase, then it should be displayed. (It will replace the dash/underscore in that spot. Spaces, punctuation, and all other non-alphabetic characters should…arrow_forwardFor the code in java below it shows a deck of 52 cards and asks the name of the two players and makes both players draw five cards from the deck. What I want to be added into the code is a way for player1 to select a one card from his deck and player2 has to select two cards from his deck that equals player1's card. If player2 can't pick two cards that equal player1's one card than player2 losses a point but if player2 can select two cards that equal player1's card tahn player2 gets a point. Main class: import java.util.ArrayList; import java.util.Scanner; import java.util.List; import java.util.Random; class Main { publicstaticvoid main(String[] args) { String[] suits = { "Hearts", "Clubs", "Spades", "Diamonds" }; String[] numbers = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" }; for (String oneSuit : suits) { for (String num : numbers) { System.out.println(oneSuit + " " + num); } } List<Player> listOfPlayers = new ArrayList<>(); Scanner sc = new…arrow_forwardIn Java, a real estate office handles 50 apartment units. When rent is $600 per month, all the units are occupied. However, for each $40 increase in rent, one unit becomes vacant. Each occupied unit requires an average of $27 per month for maintenance. How many units should be rented to maximize the profit? Write a program that prompts the user to enter: A. The number of apartment units B. The rent to occupy all the units C. The increase in rent that results in a vacant unit. D. Amount to maintain a rented unit. The program then outputs the number of unidts to be rented to maximize the profitarrow_forward
- In Java program,,,,,,,,,,,arrow_forwardUse java.arrow_forwardFor the code in java below it shows a deck of 52 cards and asks the name of the two players and makes both players draw five cards from the deck. The code also makes Player A pick a card and Player B has to pick two cards that equal the same value as Player A's card. What I want to be added to the code if for the cards that have been used to be removed and replaced with the other cards in the deck and for the next round to begin with Player B picking a card and Player A picking two cards that equal the same value as Player B's card. I also want the game to keep going between Player A and B until the cards in the deck run out. Main class code: import java.util.ArrayList; import java.util.Scanner; import java.util.List; import java.util.Random; class Main { publicstaticvoid main(String[] args) { String[] suits = {"Hearts", "Clubs", "Spades", "Diamonds"}; String[] numbers = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"}; for(String oneSuit : suits){ for(String num :…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY