Big Java Late Objects
2nd Edition
ISBN: 9781119330455
Author: Horstmann
Publisher: WILEY
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 3, Problem 18PE
Write a
Enter a month: 5 30 days
Do not use a separate if /else branch for each month. Use Boolean operators.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
C#:
Write a program that asks the user to enter a month (1 for January, 2 for February, etc.) and then prints the number of days in the month. For February, print “28 days”.
Enter a month: 5
30 days
Do not use a separate if/else branch for each month. Use Boolean operators.
Programming Language: Java
Direction: Write a program to determine the number of PASSED and FAILED out of 15 inputted names with the corresponding grade. Restrict the inputted grade for each name in the range of 50 to 100, in which 75 is the passing grade. If the inputted grade is not on the range, the program will remind the user of a message for the accepted range for the grade and allows the user to re-enter a grade.
NOTE: MUST ADD COMMENTS
Please answer in matlab code.
Chapter 3 Solutions
Big Java Late Objects
Ch. 3.1 - In some Asian countries, the number 14 is...Ch. 3.1 - Consider the following if statement to compute a...Ch. 3.1 - Prob. 3SCCh. 3.1 - Prob. 4SCCh. 3.1 - The variables fuel Amount and fuel Capacity hold...Ch. 3.2 - Which of the following conditions are true,...Ch. 3.2 - Prob. 7SCCh. 3.2 - What is the error in this statement? if (scoreA =...Ch. 3.2 - Supply a condition in this if statement to test...Ch. 3.2 - Prob. 10SC
Ch. 3.3 - In a game program, the scores of players A and B...Ch. 3.3 - Prob. 12SCCh. 3.3 - Prob. 13SCCh. 3.3 - Beginners sometimes write statements such as the...Ch. 3.3 - Prob. 15SCCh. 3.3 - Suppose we want to have the earthquake program...Ch. 3.4 - Prob. 17SCCh. 3.4 - Would that amount change if the first nested if...Ch. 3.4 - Prob. 19SCCh. 3.4 - Prob. 20SCCh. 3.4 - Prob. 21SCCh. 3.5 - Draw a flowchart for a program that reads a value...Ch. 3.5 - Prob. 23SCCh. 3.5 - Prob. 24SCCh. 3.5 - Draw a flowchart for a program that reads a value...Ch. 3.5 - Draw a flowchart for a program that reads a value...Ch. 3.6 - Prob. 27SCCh. 3.6 - Prob. 28SCCh. 3.6 - Prob. 29SCCh. 3.6 - Suppose you are designing a part of a program for...Ch. 3.7 - Suppose x and y are two integers. How do you test...Ch. 3.7 - How do you test whether at least one of them is...Ch. 3.7 - How do you test whether exactly one of them is...Ch. 3.7 - Prob. 34SCCh. 3.7 - What is the advantage of using the type boolean...Ch. 3.8 - In the ElevatorSimulation2 program, what is the...Ch. 3.8 - Your task is to rewrite lines 1926 of the...Ch. 3.8 - In the Sherlock Holmes story The Adventure of the...Ch. 3.8 - Prob. 39SCCh. 3 - What is the value of each variable after the if...Ch. 3 - Prob. 2RECh. 3 - Find the errors in the following if statements. a....Ch. 3 - What do these code fragments print? a. int n = 1;...Ch. 3 - Suppose x and y are variables of type double....Ch. 3 - Suppose x and y are variables of type double....Ch. 3 - Explain why it is more difficult to compare...Ch. 3 - Given two pixels on a computer screen with integer...Ch. 3 - It is easy to confuse the - and operators. Write...Ch. 3 - Each square on a chess board can be described by a...Ch. 3 - Prob. 11RECh. 3 - In a scheduling program, we want to check whether...Ch. 3 - Draw a flowchart for the algorithm in Exercise...Ch. 3 - Draw a flowchart for the algorithm in Exercise...Ch. 3 - Draw a flowchart for the algorithm in Exercise...Ch. 3 - Prob. 16RECh. 3 - Prob. 17RECh. 3 - Write pseudocode for a program that prompts the...Ch. 3 - Write pseudocode for a program that assigns letter...Ch. 3 - Explain how the lexicographic ordering of strings...Ch. 3 - Of the following pairs of strings, which comes...Ch. 3 - Explain the difference between an if/else if/else...Ch. 3 - Give an example of an if/else if/else sequence...Ch. 3 - Rewrite the condition in Section 3.3 to use ...Ch. 3 - Prob. 25RECh. 3 - Make up a Java code example that shows the...Ch. 3 - Complete the following truth table by finding the...Ch. 3 - True or false? A B is the same as B A for any...Ch. 3 - The advanced search feature of many search engines...Ch. 3 - Suppose the value of b is false and the value of x...Ch. 3 - Simplify the following expressions. Here, b is a...Ch. 3 - Simplify the following statements. Here, b is a...Ch. 3 - What is wrong with the following program?...Ch. 3 - Write a program that reads an integer and prints...Ch. 3 - Write a program that reads a floating-point number...Ch. 3 - Write a program that reads an integer and prints...Ch. 3 - Write a program that reads three numbers and...Ch. 3 - Write a program that reads three numbers and...Ch. 3 - Repeat Exercise E3.5, but before reading the...Ch. 3 - Write a program that reads in three integers and...Ch. 3 - Write a program that reads four integers and...Ch. 3 - A compass needle points a given number of degrees...Ch. 3 - Write a program that reads a temperature value and...Ch. 3 - The boiling point of water drops by about one...Ch. 3 - Add error handling to Exercise E3.11. If the user...Ch. 3 - When two points in time are compared, each given...Ch. 3 - The following algorithm yields the season (Spring,...Ch. 3 - Write a program that reads in two floating-point...Ch. 3 - Unit conversion. Write a unit conversion program...Ch. 3 - Write a program that prompts the user to provide a...Ch. 3 - Write a program that asks the user to enter a...Ch. 3 - Write a program that translates a letter grade...Ch. 3 - Write a program that translates a number between 0...Ch. 3 - Write a program that takes user input describing a...Ch. 3 - Write a program that reads in three floating-point...Ch. 3 - Write a program that reads in three strings and...Ch. 3 - Write a program that prompts for the day and month...Ch. 3 - The original U.S. income tax of 1913 was quite...Ch. 3 - Write a program that computes taxes for the...Ch. 3 - The TaxReturn.java program uses a simplified...Ch. 3 - Write a program that reads in the x- and...Ch. 3 - Write a program that reads in the x- and...Ch. 3 - Write a program that reads in the x- and...Ch. 3 - Roman numbers. Write a program that converts a...Ch. 3 - A year with 366 days is called a leap year. Leap...Ch. 3 - French country names are feminine when they end...Ch. 3 - Write a program to simulate a bank transaction....Ch. 3 - Write a program that reads in the name and salary...Ch. 3 - When you use an automated teller machine (ATM)...Ch. 3 - Calculating the tip when you go to a restaurant is...Ch. 3 - A supermarket awards coupons depending on how much...Ch. 3 - Write a program that prompts the user for a...Ch. 3 - Repeat Exercise P3.21, modifying the program so...Ch. 3 - Repeat Exercise P3.21, modifying the program so...Ch. 3 - A minivan has two sliding doors. Each door can be...Ch. 3 - Sound level L in units of decibel (dB) is...Ch. 3 - The electric circuit shown below is designed to...Ch. 3 - Crop damage due to frost is one of the many risks...Ch. 3 - A mass m = 2 kilograms is attached to the end of a...Ch. 3 - The average person can jump off the ground with a...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Assume a class named Dollars exists. Write the headers for member functions that overload the prefix and postfi...
Starting Out with C++ from Control Structures to Objects (9th Edition)
Is the following program legal? If so, what is the output? #include iostream #include vector using namespace st...
Problem Solving with C++ (9th Edition)
The keywordindicates that a method does not return a value.
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Write the accessors for a property named CustomerNumber that assigns a string value to the _customerNumber fiel...
Starting out with Visual C# (4th Edition)
Show a snippet of PHP code for displaying the contents of a recordset. Explain the meaning of the code.
Database Concepts (7th Edition)
What class do you use to write data to a file?
Starting Out with Java: Early Objects (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
- The two roots of a quadratic equationax2 + bx + c = 0 can be obtained using the following formula:b2 - 4ac is called the discriminant of the quadratic equation. If it is positive, theequation has two real roots. If it is zero, the equation has one root. If it is negative,the equation has no real roots.Write a program that prompts the user to enter values for a, b, and c and displaysthe result based on the discriminant. If the discriminant is positive, display tworoots. If the discriminant is 0, display one root. Otherwise, display “The equationhas no real roots.”Note you can use Math.pow(x, 0.5) to compute √x. Here are some sampleruns: Enter a, b, c: 1.0 3 1 ↵EnterThe equation has two roots -0.381966 and -2.61803arrow_forwardWrite 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_forwardWrite a program that inputs a number and a letter and then decides whether the square is a black or white square. Hint: For letters a, c, e, g you may apply a modulus 2 operation on the number to decide the result to be a black or white square. The situation is reversed for the rest of the letters. You may use a switch selection in combination with an if/else selection statement or you may use nested if/else selection statements with logical operators. You may assume the user enters valid values. Sample outputs: Enter square value: e 4 White square Enter square value: g 7 Black square C++arrow_forward
- Write aC++program that allows a user to enter their rating of the three movies in the DarkKnight Trilogy: Batman Begins/ The Dark Knight /The Dark Knight Rises Ratings must be between 1 and 5. If a rating entered is less than 1 or more than 5, display anappropriate message and do not use the rating. After all the ratings have been entered, display each rating entered, the highest rating, the lowest rating, and the average of the ratings.arrow_forwardWrite a program that calculates how much a person earns in a month if the salary is one penny the first day, two pennies the second day, four pennies the third day, and so on with the daily pay doubling each day the employee works. The program should ask the user for the number of days the employee worked during the month, validate that it is between 1 and 31, and then display a table showing how much the salary was for each day worked, as well as the total pay earned for the month. The output should be displayed in dollars with two decimal points, not in pennies.arrow_forwardYou must use switch statements instead of if-else statements. If-else statements will not be accepted for this problem. You want to learn to play an instrument, but you need to know how much it's going to cost to buy it. The music store has the following table on their website: Write a menu-driven program that asks the user to input an instrument category and then an instrument. The program should give the user the price. The user should input an integer in the range of the choices you give them (for example, a user cannot input 3 if you only have 2 choices) and in response should be prompted to for the next set of choices. Once they make the final selection, the total should be printed to them as an integer with proper formatting as shown in the sample run. Sample run: Select a category: (1)Brass (2)Woodwind (3)Percussion 2 Select an instrument: (1)Flute (2)Saxophone 2 Your instrument will be $425. Ensure you are doing input validation, output Please enter a valid input. if the user…arrow_forward
- Write an if-else statement with multiple branches. If givenYear is 2101 or greater, print "Distant future" (without quotes). Else, if givenYear is 2001 or greater (2001- 2100), print "21st century". Else, if givenYear is 1901 or greater (1901-2000), print "20th century". Else (1900 or earlier), print "Long ago". Do NOT end with newline.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_forwardAirline companies apply baggage restrictions for their passengers. An airline company has decided to apply a 10kg limitation for passengers' hand luggage and 20kg for their normal baggage. When passengers arrive, they enter their hand and normal luggage weight from the keyboard. If passengers exceed their normal baggage allowance of 10 dollars per gram, they pay 12 dollars per kg. Accordingly, write the program that calculates the baggage price of the airline they will go to according to the baggage values entered by the arriving passenger and keeps this from closing the program for each passenger. Note: If hand and normal baggage allowances are stretched below the maximum value, the payment amount will be considered not negative. An example printout is given on the right. Geri bildirim gönderarrow_forward
- Write an if statement with a condition using the random function from the random module that you would expect to be true about 30% of the time. The answer starts with if random.random(.arrow_forwardAn argument is expressed in English below. Sara is not excited. If Sara is not excited, then Sara will go to the party. Sara is sleepy. 4 : Sara will go to the party and Sara is sleepy. Variable names are assigned to each English phrase as follows: • q: Sara is excited •r: Sara will go to the party • : Sara is sleepy What is the form of the argument? Pick Pick v .: Pick 2 Check Nextarrow_forwardWrite a program that reads student scores, gets the best score, andthen assigns grades based on the following scheme:Grade is A if score is ≥ best -5Grade is B if score is ≥best -10;Grade is C if score is ≥best -15;Grade is D if score is ≥best -20;Grade is F otherwise.The program prompts the user to enter the total number of students, and thenprompts the user to enter all of the scores, and concludes by displaying the grades.Here is a sample run: Enter the number of students: 4 ↵EnterEnter 4 scores: 40 55 70 58 ↵EnterStudent 0 score is 40 and grade is FStudent 1 score is 55 and grade is CStudent 2 score is 70 and grade is AStudent 3 score is 58 and grade is Carrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningNp Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
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