Java: An Introduction to Problem Solving and Programming (7th Edition)
7th Edition
ISBN: 9780133766264
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 4, Problem 9P
What’s for dinner? Let the computer decide. Write a
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a program that asks the user how many credit units they have taken. If they have taken 23 or less, print that the student is a freshman. If they have taken between 24 and 53, print that they are a sophomore. The range for juniors is 54 to 83, and for seniors it is 84 and over.
Hello..Its no correct....Can you help me?
Guess-the-number-game: Write a program that pays the game of “guess
the number” as follows: Your program choose the number to be guess by
selecting an integer at random in the range 1 to 1000. The program then
displays the following:
I have a number between 1 and 1000.
Can you guess my number?
Please type your first guess.
The player then type a first guess. The program responds with one of the
following:
1. Excellent ! you guessed the number!
Would like to play again (y or n)?
2. Too low. Try again.
3. Too high. Try again.
If the payer’s guess is incorrect, your program should loop until the player
finally get the number right. Your program should keep telling the player
Too high or Too low to help the player “zero in” on the correct answer.
Chapter 4 Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
Ch. 4.1 - What output is produced by the following code? int...Ch. 4.1 - Can the body of a while loop execute zero times?...Ch. 4.1 - What output is produced by the following code? int...Ch. 4.1 - Revise the following code so that it uses a while...Ch. 4.1 - What output is produced by the following code? int...Ch. 4.1 - Imagine a program that reads the population of a...Ch. 4.1 - Prob. 7STQCh. 4.1 - What output is produced by the following code? int...Ch. 4.1 - What output is produced by the following code? for...Ch. 4.1 - What output is produced by the following code? for...
Ch. 4.1 - Prob. 11STQCh. 4.1 - Write a for statement that displays the even...Ch. 4.1 - Prob. 13STQCh. 4.2 - Write a Java loop that will display the phrase One...Ch. 4.2 - Write a Java loop that will set the variable...Ch. 4.2 - Write a Java loop that will read a list of numbers...Ch. 4.2 - What output is produced by the following code? for...Ch. 4.2 - What output is produced by the following code? for...Ch. 4.2 - What output is produced by the following code? for...Ch. 4.2 - Revise the loop shown in Listing 4.6 to use a...Ch. 4.2 - What is the bug in the code in the section Tracing...Ch. 4.2 - Add some suitable output statements to the...Ch. 4.2 - What is the bug in the code in the previous...Ch. 4.2 - Prob. 24STQCh. 4.2 - Suppose that you did not have assertion checking...Ch. 4.3 - Prob. 26STQCh. 4 - Write a fragment of code that will read words from...Ch. 4 - Develop an algorithm for computing the...Ch. 4 - Develop an algorithm for a simple game of guessing...Ch. 4 - Write a fragment of code that will compute the sum...Ch. 4 - Convert the following code so that it uses nested...Ch. 4 - Write a for statement to compute the sum 1 + 22 +...Ch. 4 - (Optional) Repeat the previous question, but use...Ch. 4 - Write a loop that will count the number of blank...Ch. 4 - Write a loop that will create a new string that is...Ch. 4 - Write a program that will compute statistics for...Ch. 4 - Suppose we attend a party. To be sociable, we will...Ch. 4 - Define an enumeration for each of the months in...Ch. 4 - Write a fragment of code that computes the final...Ch. 4 - Suppose that you work for a beverage company. The...Ch. 4 - Suppose that we want to compute the geometric mean...Ch. 4 - Prob. 16ECh. 4 - Create an applet that draws a pattern of circles...Ch. 4 - Prob. 18ECh. 4 - What does the following fragment of code display?...Ch. 4 - Repeat Practice Program 4 of Chapter 3, but use a...Ch. 4 - Write a program that implements your algorithm...Ch. 4 - Repeat Practice Program 5 of Chapter 3, but use a...Ch. 4 - Write a program to read a list of nonnegative...Ch. 4 - Write a program to read a list of exam scores...Ch. 4 - Combine the programs from Programming Projects 5...Ch. 4 - Write a program that simulates the Magic 8 Ball...Ch. 4 - Whats for dinner? Let the computer decide. Write a...Ch. 4 - Write a program that implements your algorithm...Ch. 4 - Prob. 2PPCh. 4 - Write a program that reads a bank account balance...Ch. 4 - Modify Programming Project 5 from Chapter 2 to...Ch. 4 - Write a program that asks the user to enter the...Ch. 4 - Write a program that simulates a bouncing ball by...Ch. 4 - You have three identical prizes to give away and a...Ch. 4 - Prob. 9PPCh. 4 - Holy digits Batman! The Riddler is planning his...Ch. 4 - Your country is at war and your enemies are using...Ch. 4 - Prob. 12PPCh. 4 - Prob. 13PPCh. 4 - Prob. 14PPCh. 4 - Prob. 15PPCh. 4 - Prob. 16PP
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Write SQL queries to answer the following questions: How many students are enrolled in Section 2714 in the firs...
Modern Database Management
Write a program to print the value of EOF.
C Programming Language
Why doesn't the following pseudocode module work as indicated in the comments? // The readFile method accepts a...
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
What is pseudocode?
Starting Out With Visual Basic (7th Edition)
Explain why software testing should always be an incremental, staged activity. Are programmers the best people ...
Software Engineering (10th Edition)
It is not possible to call a superclasss _ _init_ _ method from a subclasss _ _init_ _ method.
Starting Out with Python (3rd Edition)
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
- Write a program that prints the insurance fee to pay for a pet according to the following rules: (Note: must use a switch statement to determine pet fee) A dog that has been neutered costs $50.A dog that has not been neutered costs $80.A cat that has been neutered costs $40.A cat that has not been neutered costs $60.A bird or reptile costs nothing.Any other animal generates an error message. The program should prompt the user for the appropriate information: a character code for the pet type, and a yes/no response for the neutered status. Use a code letter to determine the kind of animal (i.e. D or d represents a dog, C or c represents a cat, B or b represents a bird, R or r represents a reptile, and anything else represents some other kind of animal). Use a code letter to determine the neutered status(i.e. Y or y represents yes, N or n represents no). The user should be allowed to enter the input in either upper or lower case. It prints out the type of animal (full name of animal)…arrow_forwardAlyssa is very particular about what she gets for dinner. The more hungry she is, the more she can not figure out what to eat! Write a short program that asks a few questions and then makes the correct suggestion based on the following rules: Alyssa considers any temperature below 50 to be cold and anything 50 and above to be warm. If it is cold and raining, Alyssa wants to have soup. If none of these rules apply, Alyssa will always have meatballs. Alyssa has to eat before class starts! When it is 15 minutes or less until class, she gets a sandwich. This is the most important rule. Your program should prompt the user with the following. Enter temperature (0 to 100): Enter weather (sunny, raining): Enter minutes until class starts (0 to 60): Below is sample input to test your program. 40 raining 30 Your program should output the following. soup Code Skeleton: import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new…arrow_forwardSimulate the dice game of lucky sevens. The rules are: roll two dice if the sum equals 7, win $4 if the sum is not 7, lose $1 Write a program that asks the user how much they would like start the game with. The program should then: simulate the dice roll (using the random function) and show what was rolled show what the user’s funds are after each roll ask the user if they want to roll again if the user wants to roll again, repeat the three actions above if the user does not want to roll again give some response and end the game the final output should show if they won or lost money, and how many rolls they playedarrow_forward
- You arrive in front of a bridge that you must cross to reach a village before dark. Crossing the bridge is not free - the bridgekeeper asks you to roll two dice to determine the cost. You decide to write a program to verify that he is charging the right price. Your program should read two integers, between 1 and 6, representing the values of each die. If the sum is greater than or equal to 10, then you must pay a special fee (36 coins). Otherwise, you pay twice the sum of the values of the two dice. Your program must then display the text "Special tax" or "Regular tax" followed by the amount you have to pay on the next line.arrow_forwardWrite a program that helps a company manage salaries of its employees. Your program should ask for the number of hours worked and the hourly rate of an employee than, display the salary. This program still asks the user to enter the information of many employees until enters a zero value. Sample Run: Enter the number of hours worked (negative nbr to end): 32 Enter hourly rate of the worker: 100 Your salary is $3200 Enter the number of hours worked (negative nbr to end): 40 Enter hourly rate of the worker: 5 Your salary is $200 Enter the number of hours worked (negative nbr to end): 42 Enter hourly rate of the worker: 10 Your salary is 5420 Enter the number of hours worked (negative nbr to end): 0arrow_forwardWrite a program that prints the numbers from 1 to 100, except if the number is divisible by 3 print 'Beep' instead of the number and if it is divisible by 5 print 'Boop'. For numbers which are divisible by both 3 and 5 print 'BeepBoop'. (See the output below: 3 and 6 are replaced by 'Beep'; 5 and 10 are replaced by 'Boop'; 15 and 30 are replaced by 'BeepBoop') Use a for loop.arrow_forward
- solve using paython language and take screenshot contains the codearrow_forwardAlert dont submit AI generated answer.arrow_forwardWrite a program that asks for the names of three runners and the time it took each of them to finish a race. The program should display who came in first, second, and third place. Think about how many test cases are needed to verify that your problem works correctly. (That is, how many different finish orders are possible?) Input Validation: Only allow the program to accept positive numbers for the times.arrow_forward
- This example creates a program to teach a first grade child how to learn subtractions. The program randomly generates two single- digit integers number1 and number2 with number1 > number2 and displays a question such as "What is 9 – 2?" to the student. After the student types the answer, the program displays a message to indicate whether the answer is correct.arrow_forwardphytonarrow_forwardWrite a program that prompts the user to enter an integer. If the number is a multiple of 5, print HiFive. If the number is divisible by 2, print HiEven.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
Constants, Variables, Data types, Keywords in C Programming Language Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=d7tdL-ZEWdE;License: Standard YouTube License, CC-BY