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 3.1, Problem 4STQ
Suppose speed and visibility are variables of type int. Write an if statement that sets the variable speed equal to 25 and displays the word Caution, provided the value of speed is greater than 25 and the value of visibility is under 20. There is no else part.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Suppose that sale and bonus are double variables. Write an if...else statement that assigns a value to bonus as follows: If sale is greater than $20,000, the value assigned to bonus is 0.10, that is 10%; If sale is greater than $10,000 and less than or equal to $20,000, the value assigned to bonus is 0.05, that is 5%; otherwise the value assigned to bonus is 0, that is 0%.
Suppose goals is a variable of type int. Write an if-else statement that displays the word Wow if the value of the variable goals is greater than 10 and displays the words Oh Well if the value of goals is at most 10.
Assume a and b are int variables. Give the logical opposites of each of the following expressions; that is, give an expression that is False exactly when the given expression is True and vice versa. You may NOT use the not operator - but you can use or and/or and.
1. a!= b
2. a > b
3. a >= 47 and day != 3
4. a == 47 or day == 3
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
The Fibonacci numbers F are defined as follows. F is 1, F is 1, and Fi+2 = Fi + Fi+1 i = 0, 1, 2, . In other w...
Problem Solving with C++ (9th Edition)
A magic number is _______. a. a number that is mathematically undefined b. an unexplained value that appears in...
Starting Out with Python (4th Edition)
Using the f , r , and i functions from preceding exercises, write a function called r that takes three characte...
Programming in C
The ____________ is always transparent.
Web Development and Design Foundations with HTML5 (8th Edition)
Write an expression that is a 1 when one or more of its variables (A 6, and C) are Os.
Digital Fundamentals (11th Edition)
What is the output of the following program lines?
Absolute Java (6th 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
- Language is VB Write a selection statement (if .....then .... else .... end-if) that evaluates a voter age to allow her/him to vote. If age is equal or greater than 18 then display the message 'you can vote.' ,otherwise display "you are too young to vote" on a label control or object . You pick the name for the integer variable whose content is the number indicating the age and pick a name for the label whose content indicating the appropriate message. if ........ then ............. else .......... end-ifarrow_forward29. If originally x=4, what is the value of x after the evaluation of the expression: x -=4arrow_forwardExercise I- Medicine Write a program that asks the user to enter the name of the medicine (t for ThroX, f for FeliX), his mass. The user should enter as well if he has a prescription or not. The program will calculate the dosage using: age and his ThroX without prescription -The max dosage should be 0.75 mL -The dosage = mass / 150 -The number of pills per day to take is 1 ThroX with prescription -The dosage =mass * 3 / 150 -The number of pills per day to take is 5 FeliX with prescription -The dosage = 0.77 mL FeliX without prescription -The dosage should be between 0.3 and 0.7 -The dosage = mass * 0.009 -The number of pills per day to take is 2 -The number of pills per day to take is 6 The program should display the dosage and the number of pills to be taken per day if the requirements are full filled, otherwise it display "Please check your doctor for a prescription". In case the medicine does not exist in the database, the program display “Your medicine is not in our database!"…arrow_forward
- 5. Write an efficient if statement to assign x the value 1 if x ≤ 1.5, 2 if 1.5arrow_forwardAssume that d is a double variable. Write an if statement that assigns d to the int variable i if the value in d is not larger than the maximum value for an int. i (int) d; System.out.println(i); } Submit X Incorrect. Try again.arrow_forwardVariables father and child contains ages of a father and his child.Which if statement checks if father's age is more than 4 times his child's age? Lütfen birini seçin: a. if father // 4 > child: b. if father > 4 * child: c. if father > 4 * child d. if f > 4 * c: e. if father >= 4 * child:arrow_forward
- 3. Write an if...else python statement that determines whether a variable called speed is inside the range of 0 to 200 (inclusive). If the variable is inside this range it should display "Valid Speed". Otherwise, it should display "Invalid Speed".arrow_forwardWrite an if with and else if and an else. The conditions of the if and else if should evaluate an int variable named age (you don't have to worry about this variable or any Scanners or main or anything else). Inside the body of the three parts (if, else if, and else) print out something that a person in the corresponding age would know about from their childhood. All three print statements should be reachable.arrow_forwardWrite an if-else statement that works like this: If the sales variable is greater- than or equal-to 50,000, the commissionRate variable should be assigned the value 0.2. Otherwise, the commissionRate variable should be assigned the value 0.1.arrow_forward
- 2. Write an if...else statement that determines whether a variable called points is outside the range of 9 to 51 (exclusive). If the variable is outside this range it should display "Invalid points". Otherwise, it should display "Valid points". 3. Write an if...else statement that determines whether a variable called speed is inside the range of 0 to 200 (inclusive). If the variable is inside this range it should display "Valid Speed". Otherwise, it should display "Invalid Speed".arrow_forwardWrite an if-else statement that works like this: If the sales variable is greaterthan or equal-to 50,000, the commissionRate variable should be assigned the value 0.2. Otherwise, the commissionRate variable should be assigned the value 0.1.arrow_forwardComputer Fundamentals and Programming 2 Write a program that determines a student’s grade. The program will accept 3 scores and computes the average score. Determine the grade based on the following rules: - If the average score is equal or greater than 90, the grade is A. - If the average score is greater than or equal to 70 and less than 90, the grade is B. - If the average score is greater than or equal to 50 and less than 70, the grade is C. - If the average score is less than 50, the grade is F. Source Codes and Print Screen of the Outputarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Control Structure in Data Structure - Data Structures - Computer Science Class 12; Author: Ekeeda;https://www.youtube.com/watch?v=9FTw2pXLhv4;License: Standard YouTube License, CC-BY