EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
expand_more
expand_more
format_list_bulleted
Question
Chapter 5, Problem 5PE
a.
Program Plan Intro
Display a specified message for the entered date
Program plan:
- Import necessary package.
- Create a class “PastPresentFuture”,
- Define the method “main ()”,
- Declare the necessary variables.
- Create an object for “LocalDate” class.
- Create “Scanner” object.
- Assign the month value returned from the method “getMonthValue()”.
- Assign the day value returned from the method “getDayOfMonth()”.
- Assign the month value returned from the method “getYear()”.
- Prompt the user to enter the month, day, and year.
- Get the month, day and year from the user.
- Check whether the year is a today’s year,
- If it is true, print the related message.
- Otherwise, check whether the month is today’s month,
- If it is true, print the related message.
- Otherwise, check whether the day is same as today,
- If it is true, print the related message.
- Otherwise, print the month related message.
- Define the method “main ()”,
b.
Program Plan Intro
Display a specified message for the entered date
Program plan:
- Import necessary package.
- Create a class “PastPresentFuture2”,
- Define the method “main ()”,
- Declare the necessary variables.
- Create an object for “LocalDate” class.
- Create another instance variable for “LocalDate” class.
- Create “Scanner” object.
- Assign the month value returned from the method “getMonthValue()”.
- Assign the day value returned from the method “getDayOfMonth()”.
- Assign the month value returned from the method “getYear()”.
- Prompt the user to enter the month, day, and year.
- Get the month, day and year from the user.
- Assign the values in a date format.
- Check whether the entered date is a past date,
- If it is true, print the related message that indicates the past date.
- Otherwise, check whether the date is the current date,
- If it is true, print the related message that indicates the current date.
- Otherwise, print the month related message that indicates the future date.
- Define the method “main ()”,
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
a. Write an application that prompts a user for a month, day, and year. Display a message that specifies whether the entered date is (1) not this year, (2) in an earlier month this year, (3) in a later month this year, or (4) this month. Save the file as PastPresentFuture.java.
b. Use the web to learn how to use the LocalDate Boolean methods isBefore(), isAfter(), and equals(). Use your knowledge to write a program that prompts a user for a month, day, and year, and then displays a message specifying whether the entered day is in the past, the current date,or in the future. Save the file as PastPresentFuture2.java.
Write an application to pre-sell a limited number of cinema tickets. Each buyer can buy as many as 4 tickets. No more than 100 tickets can be sold. Implement a program called Ticket Seller that prompts the user for the desired number of tickets and then displays the number of remaining tickets. Repeat until all tickets have been sold, and then display the total number of buyers.
Create a Java application which will take an infix algebraic expression as an input from user. It will check that whether it is a valid expression or not. Then It will be converted into postfix expression, and at the end it will be evaluated and print the result of the expression. For example:if input is: (3+5)*(7output: it is invalid.If input is: (3+5)*7 , displayPostfix form: 35+7*Answer: 56.
Chapter 5 Solutions
EBK JAVA PROGRAMMING
Ch. 5 - Prob. 1RQCh. 5 - Prob. 2RQCh. 5 - Prob. 3RQCh. 5 - Prob. 4RQCh. 5 - Prob. 5RQCh. 5 - Prob. 6RQCh. 5 - Prob. 7RQCh. 5 - Prob. 8RQCh. 5 - Prob. 9RQCh. 5 - Prob. 10RQ
Ch. 5 - Prob. 11RQCh. 5 - Prob. 12RQCh. 5 - Prob. 13RQCh. 5 - Prob. 14RQCh. 5 - Prob. 16RQCh. 5 - Prob. 17RQCh. 5 - Prob. 18RQCh. 5 - Prob. 19RQCh. 5 - Prob. 20RQCh. 5 - Prob. 1PECh. 5 - Prob. 2PECh. 5 - Prob. 3PECh. 5 - Prob. 4PECh. 5 - Prob. 5PECh. 5 - Prob. 6PECh. 5 - Prob. 7PECh. 5 - Prob. 8PECh. 5 - Prob. 9PECh. 5 - Prob. 10PECh. 5 - Prob. 1GZCh. 5 - Prob. 2GZCh. 5 - Prob. 3GZCh. 5 - Prob. 4GZCh. 5 - Prob. 5GZ
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
- Create an application in Java that uses card layout with three cards. The first card - a login card - should have two text fields, one for username and other for password. There are two users - Bob and Fred - whose passwords are "mubby and "goolag" respectively. If Bob logs in, switch to a card - the bob card - that has a text field, a text area and two buttons. If the first button is pressed, get the text from the text field and append it to the text area. If the second button is pressed, return to the login card. If Fred logs in, switch to a card - the fred card - that has three buttons. If the first button is pressed, change the background color to green. If the second button is pressed, change the background color to red. If the third button is pressed, return to login card.arrow_forwardWrite a program that lets the user play the slot machine (https://en.wikipedia.org/wiki/Slot_machine).A slot machine features a screen displaying three or more reels. To play, the user inserts money and activates the machine by means of a lever or button (either physical or on a touchscreen). The reels then spin and stop to rearrange the symbols. If the rearranged symbols match a winning combination, the player earns points based on a pay table. Symbols vary depending on the theme of the machine. Classic symbols include objects such as fruits, bells, and stylized lucky sevens.In this assignment, we slightly modify the operating mode of the slot machine as follows. Instead of the user manually activating the machine every time they want to play, the program will automatically play on behalf of the user multiple times. The user can choose from the following menu:1-> Play n times. The machine will repeatedly play n times.2-> Play until the credit gets below a minimum value. The…arrow_forwardThis must be done in Java.util.scanner. Class. Everything must have comments Write a Java application that displays two dialog boxes in sequence. The first asks you to think of a number between 1 and 10. The second displays a randomly generated number; the user can see whether his or her guess was accurate. (In future chapters, you will improve this game so that the user can enter a guess and the program can determine whether the user was correct. If you wish, you also can tell the user how far off the guess was, whether the guess was high or low, and provide a specific number of repeat attempts.) Save the file as RandomGuess.javaarrow_forward
- Task 5: ScanningMoney.java Write a program that reads User Input using the Scanner class. Your program should ask the user how many quarters, nickels, dimes, and pennies they have, then display the total amount in dollars. This can be done in main method. Expected Output The highlighted text denotes text that you type into the console yourself. It is not printed by the program. Due to floating point values being used your answer may have the trailing 1 or not. ----JGRASP exec: java ScanningMoney Quarters: 4 Dimes: 3 Nickels: 2 Pennies: 1 You have $1.4100000000000001 ----JGRASP: operation complete.arrow_forwardPlease help me with the question on the picturearrow_forwardWrite a program that asks the user to enter four words. The program should then analyze each of the four words so that it can report the length of each word as well as the positions of the five vowels within each word.arrow_forward
- Write an application that determines whether a phrase entered by the user is a palindrome. A palindrome is a phrase that reads the same backward and forward without regarding capitalization, spaces or punctuation. And it will allow the user to enter as many phrases as he likes after each iteration.arrow_forwardUsing the implementation of the IPAddresses class developed in this chapter, write a method that displays the IP addresses stored in the class in ascending order. Use the method in a programarrow_forwardwrite using javascriptarrow_forward
- Help me modify my MaxSentinel Java Program(Attached image & Pasted Java Code) into a new program called MaximumSent... 1. Check for valid first entry. Then allow the user to enter as many numbers as desired. 2. If invalid number entered, print "Invalid entry." Prompt the user again until a valid number is entered. 3. Once -1 is entered, program stops and prints the largest number entered. Submit final code. JAVA CODE for MaxSentinel, has been pasted below: (also view attached images) import java.util.Scanner; public class MaxSentinel{ public static void main(String[] args) { Scanner input=new Scanner(System.in); int num=0,max=-1; System.out.print("Enter positive integers(-1 to stop):"); num=input.nextInt(); while(num!=-1) { if(num>max) max=num; System.out.print("Enter positive integers(-1 to stop):"); num=input.nextInt(); } System.out.println("Largest number: "+max); }}arrow_forwardCreate a java program that reads integers from the user until the enter key is pressed. Oncea allof the integers have been read your program should display all of the negativen numbers followed by all of the zeros, followed by all of the positive numbers. Withine eachgroup the numbers should be displayed in the same order that they were enteredbyt theuser. For example, if the user enters the values 3, -4, 1, 0, -1, 0, and -2 thenyourp programshould output the values -4, -1, -2, 0, 0, 3, and 1. Your programshould displaye eachvalue on its own line.arrow_forwardYou have been asked to develop the new system. You are to write an application to assign seats in an airline. Assume a small airplane with 28 seats (7 rows 4 wide) as follows: 1 A B C D 2 A B C D 3 A B C D 4 A B C D 5 A B C D 6 A B C D 7 A B CD The program should display the seat pattern, with an X marking the seats already assigned. 1 X B C D 2 A X C D 3 A B C D 4 A B X D 5 A B C D 6 A B C D 7 A B C D The program then requests a choice of seat. If the seat if available,then the seating display is updated. Otherwise, the program requests another choice of seat. If the user types in a seat that is already assigned, the program should say that that seat is occupied and ask for another choice. This continues until all seats are filled or until the user says that the program should end.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
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,
Files & File Systems: Crash Course Computer Science #20; Author: CrashCourse;https://www.youtube.com/watch?v=KN8YgJnShPM;License: Standard YouTube License, CC-BY
UNIX Programming (Part - 10) The File System (Directories and Files Names); Author: ITUTEES;https://www.youtube.com/watch?v=K35faWBhzrw;License: Standard Youtube License