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
Textbook Question
Chapter 3.4, Problem 23STQ
Write code for a JOptionPane dialog that will ask whether the user is at least 18 years of age. Then set the boolean variable adult equal to either true, if the user is at least 18, or false otherwise. Include the declaration of the variable adult.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Q1: Write a program that allows a user to enter a string
containing a day of the week ('Sunday', 'Monday', 'Tuesday',
etc.), and uses a switch construct to convert the day to its
corresponding number, where Sunday is considered the first
day of the week, and Saturday is considered the last day of the
week. Print out the resulting day number. Also, be sure to
handle the case of an illegal day name with an otherwise
statement!
OBJECT: To compute the net pay of an employee, given his/her pay rate, number of hours, and tax rate.
INPUT: his/her name, pay rate, and number of hours. You will prompt the user with a friendly message to enter the employee’s name, pay rate and number of hours.
Note that you must use the dash (-) to connect the first name to the last name so that the name can be read using the cin statement. For example, John-Doe
OUTPUT: the employee’s gross pay, tax deduction, and net pay. For example:
Name: John-Doe
Your gross pay is: 900.00
Your tax deduction is: 90.00
Your net pay is: 810.00
METHOD: the gross pay is the pay rate times the number of hours.
The tax deduction is computed as follows: If the gross pay is less than 1000.00, it is 10% of the total pay; otherwise, it is 15% of the gross pay.
The net pay is the gross pay minus the tax deduction.
TOPICS:…
An argument is expressed in English below.
Rhys will go to the beach.
If Rhys is excited; then Rhys will go to the beach.
Rhys is excited.
Variable names are assigned to each English phrase as follows:
p: Rhys is excited
•q: Rhys will go to the beach
Is the argument valid? If valid, then indicate which rule is used for the
argument. If invalid, then give truth assignments to the variables that
prove the argument is invalid.
Pick
4.
Check
Next
Chapter 3 Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
Ch. 3.1 - Suppose goals is a variable of type int. Write an...Ch. 3.1 - Suppose goals and errors are variables of type...Ch. 3.1 - Suppose salary and deductions are variables of...Ch. 3.1 - Suppose speed and visibility are variables of type...Ch. 3.1 - Suppose salary and bonus are variables of type...Ch. 3.1 - Assume that nextWord is a string variable that has...Ch. 3.1 - Prob. 7STQCh. 3.1 - What output is produced by the following code? int...Ch. 3.1 - Suppose you change the code in the previous...Ch. 3.1 - What output is produced by the following code? int...
Ch. 3.2 - Suppose number is a variable of type int that has...Ch. 3.2 - What output is produced by the following...Ch. 3.2 - What output is produced by the following...Ch. 3.2 - What output is produced by the following...Ch. 3.3 - What output is produced by the following code?Ch. 3.3 - Suppose you change the code in the previous...Ch. 3.3 - What output is produced by the following code?Ch. 3.3 - What output is produced by the following code?Ch. 3.3 - Suppose you change the first line of the code in...Ch. 3.3 - Prob. 20STQCh. 3.4 - Prob. 21STQCh. 3.4 - Prob. 22STQCh. 3.4 - Write code for a JOptionPane dialog that will ask...Ch. 3 - Write a fragment of code that will test whether an...Ch. 3 - Write a fragment of code that will change the...Ch. 3 - Suppose you are writing a program that asks the...Ch. 3 - Prob. 4ECh. 3 - Consider the following fragment of code: What is...Ch. 3 - We would like to assess a service charge for...Ch. 3 - What is the value of each of the following boolean...Ch. 3 - The following code fragment will not compile. Why?...Ch. 3 - Prob. 9ECh. 3 - Consider the boolean expression (2 5) (x 100))....Ch. 3 - Write a switch statement to convert a letter grade...Ch. 3 - Consider the previous question, but include + or ...Ch. 3 - Imagine a program that displays a menu of five...Ch. 3 - Repeat the previous exercise, but define an...Ch. 3 - Repeat Exercise 13, but use a multibranch if-else...Ch. 3 - Given that the int variable temp contains a...Ch. 3 - Write Java statements that create a yes-or-no...Ch. 3 - A number x is divisible by y if the remainder...Ch. 3 - Write a program to read in three nonnegative...Ch. 3 - Write a program that reads three strings from the...Ch. 3 - Write a program that reads a one-line sentence as...Ch. 3 - Write a program that allows the user to convert a...Ch. 3 - Write a program that inputs an integer. If the...Ch. 3 - Prob. 7PCh. 3 - Repeat Programming Project 5 of Chapter 2, but...Ch. 3 - Repeat any of the previous Practice Programs using...Ch. 3 - Suppose that we are working for an online service...Ch. 3 - Write a program that reads a string from the...Ch. 3 - Repeat the calorie-counting program described in...Ch. 3 - Repeat Programming Project 5 but in addition ask...Ch. 3 - Repeat Programming Project 11 in Chapter 2, but if...Ch. 3 - Write a program to play the rock-paper-scissor...Ch. 3 - Prob. 9PPCh. 3 - Repeat Programming Project 8 in Chapter 1, but add...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
When a program has a lot of items for the user to select from, why should you avoid displaying all of the items...
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
(Hugelnteger Class) Create a class Hugelnteger that uses a 40-element array of digits to store integers as larg...
C How to Program (8th Edition)
Consider the adage Never ask a question for which you do not want the answer. a. Is following that adage ethica...
Experiencing MIS
You have been asked to test a method called catWhiteSpace in a Paragraph object that, within the paragraph, rep...
Software Engineering (10th Edition)
Assume a class named Inventory keeps track of products in stock for a company. It has member variables prodID, ...
Starting Out with C++: Early Objects
Repeat Problem 8 for a 4-input OR gate.
Digital Fundamentals (11th 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
- what is If...Then...Else statement ?arrow_forwardWrite an application that reads an integer and determines and prints whether it’s odd or even. [Hint: Use the remainder operator. An even number is a multiple of 2. Any multiple of 2 leaves a remainder of 0 when divided by 2.]arrow_forwardCan you please help write this with java levelarrow_forward
- A magic date is one when written in the following format, the month times the date equals the year e.g. 6/10/60. Write code that figures out if a user entered date is a magic date. The dates must be between 1 - 31, inclusive and the months between 1 - 12, inclusive. Let the user know whether they entered a magic date. If the input parameters are not valid, return false. examples: magicDate(6, 10, 60) -> truemagicDate(50, 12, 600) -> falsearrow_forwardA video player plays a game in which the character competes in a hurdle race. Hurdles are of varying heights, and the characters have a maximum height they can jump. There is a magic potion they can take that will increase their maximum jump height by unit for each dose. How many doses of the potion must the character take to be able to jump all of the hurdles. If the character can already clear all of the hurdles, return . Example The character can jump unit high initially and must take doses of potion to be able to jump all of the hurdles. Function Description Complete the hurdleRace function in the editor below. hurdleRace has the following parameter(s): int k: the height the character can jump naturally int height[n]: the heights of each hurdle Returns int: the minimum number of doses required, always or more Input Format The first line contains two space-separated integers and , the number of hurdles and the maximum height the character can jump naturally.The…arrow_forwardIt is given twelve balls of identical weight with the exception of one that is either heavier or lighter. Additionally, it is equipped with a dual-pan balance. Utilization of the balance in each instance You may place any number of the 12 balls on the left pan and the same number on the right pan, and then press a button to begin weighing; there are three potential outcomes: the weights are equal, the balls on the left are heavier, or the balls on the left are lighter. Create a technique for determining which ball is the odd one out and whether it is heavier or lighter than the others using the balance in the fewest feasible instances. Solve the issue of weighing 39 balls, one of which is known to be odd.arrow_forward
- In admissions to military high schools, the age of the candidate should be between 13 - 17 (including lower and upper limit) and body mass index should be in the range of 18.50 - 24.99 (including lower and upper limit). (Body mass index is calculated by dividing weight by the square of height in meters. BMI = weight / height2). Write the JAVa program on the screen that will show whether the candidate will be admitted to military high school according to age, weight and height information entered on the keyboard.arrow_forwardplz solve it asap ????????: Write a program for a game that consists of two players. The rule of the game is that player 1 inputs a random number from 1-100. Player 2 will input 5 numbers. If the summation of those numbers is equal to the number OR less than or greater than the number by 3 (+3 or -3), then player 2 wins. Otherwise, player 1 wins. Test Case 1 Input Player 1, enter a number: 50 Player 2, enter a number: 10 Player 2, enter a number: 10 Player 2, enter a number: 20 Player 2, enter a number: 5 Player 2, enter a number: 7 Output Player 2 wins Explanation: The summation of 10,10,20,5 and 7 is 52 which is greater than 50 by 2. According to the rule, player 2 wins. Test Case 2 Input Player 1, enter a number: 50 Player 2, enter a number: 10 Player 2, enter a number: 10 Player 2, enter a number: 20 Player 2, enter a number: 5 Player 2, enter a number: 1 Output Player 1 wins Explanation: The summation of 10,10,20,5 and 1 is 46 which is less than 50 and also doesn’t…arrow_forwardWrite a Java code to accept temperature value from user (in centigrade) and display an appropriate message as below. FREEZING if temperature in less than 0 COLD if temperature is between0 to 15 WARM if temperature is between16 to 30 HOT if temperature is between31 to 40 VERY HOT if temperature is greaterthan 40arrow_forward
- A retail company assigns a $5000 store bonus if monthly sales are $100,000 or more. Additionally, if their sales exceed 125% or more of their monthly goal of $90,000, then all employees will receive a message stating that they will get a day off. Step 3: Complete the pseudocode by writing the missing lines. When writing your modules and making calls, be sure to pass necessary variables as arguments and accept them as reference parameters if they need to be modified in the module. (Reference: Writing a Decision Structure in Pseudocode, page 118). Module main () //Declare local variables Declare Real monthlySales //Function calls Call getSales(monthlySales) ______________________________________________________ ______________________________________________________ End Module //this module takes in the required user input Module getSales(Real Ref monthlySales) Display “Enter the total sales for…arrow_forwardThe objective of this program is to demonstrate your proficiency with the if-elif-else construct. Your program will consist of a simple guessing game. Using the random module, generate an integer between 1 and 10. This will be the secret. You will then ask the user for a guess between 1 and 10. . If the guess is greater than the secret respond, "Too high". • If the guess is less than the secret respond, "Too low". . If both numbers are equal respond, "Success!". Remember to test your program to ensure that all of the comparisons work. Please note that a loop is not required. The images below shows the program being run multiple times to display the three different possible output messages. Your display should look like this. User input is highlighted in green. Please enter your guess: 10 Too high! Please enter your guess: 5 Too low! Please enter your guess: 1 Success!arrow_forwardWrite a Java code to accept temperature value from user (in centigrade) and display an appropriate message as below. FREEZING if temperature in less than 0 COLD if temperature is between 0 to 15 WARM if temperature is between 16 to 30 HOT if temperature is between 31 to 40 VERY HOT if temperature is greater than 40arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY