Introduction to Java Programming and Data Structures, Comprehensive Version Plus MyProgrammingLab with Pearson EText -- Access Card Package
11th Edition
ISBN: 9780134694511
Author: Liang, Y. Daniel
Publisher: Pearson Education Canada
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
In JAVA,
Write a program to find the sum of all numbers divisible by 5 in the range 1 to 100.
Chapter 4 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version Plus MyProgrammingLab with Pearson EText -- Access Card Package
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
Modify the temperature conversion program to print a heading above the table.
C Programming Language
Does the loop in the following routine terminate? Explain your answer. Explain what might happen if this routin...
Computer Science: An Overview (12th 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 (10th Edition)
When displaying a Java applet, the browser invokes the _____ to interpret the bytecode into the appropriate mac...
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Given the following variable declarations: f s l d and the seven steps outlined in this chapter for conversion ...
Programming in C
Describe the role of data dictionary in the management and maintenance of a database.
Modern Database Management
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
- Program in java to print the number in the range in which upper limit is given that is 945 and you have to take lower value from the user and print the inner values between them WITHOUT ANY LOOP.IN JAVAarrow_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
- How would I solve this in Java? it has to: return a string for the day of the week, param offset -the offset from Thursday, and return the name of day of the week.arrow_forwardThis 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_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 PLEASEarrow_forward
- Use 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_forwardHi I was given help with the problem with the java programming 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 was able to code up to the point of where I got an error. I'm not sure where i'm off. I tried re-doing my code but I get the same problem with my opening and closing bracket. Here's the code thus far: import java.util.Scanner; public class ModuleP3 { public static void main(String[] args) {Scanner input = new Scanner(System.in);int num1 = (int)(Math.random()*100+1);System.out.println("Enter the number between 1 and 4: ");int userinput = input.nextInt();for(int i=1;i<=4;i++){ if(i==userinput){if(num1%userinput==0){System.out.println("The given input" + userinput + "is a factor of generated random number" + num1);}else{System.out.println("The generated random number is:" + num1); System.out.println("The given input…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY