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
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.
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.
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
- Write 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_forwardUsing the Java programming language write a program that takes an email address as an input from the keyboard and, using a loop, steps through every character looking for an @ sign. If the email address has exactly one @ character, then print a message that the email address is valid; otherwise, print a message that it is invalid.arrow_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_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_forwardWrite 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_forward
- This is the question - Write an application that prompts a user for a month, day, and year. Then display the appropriate message: Y is not this year M was a month earlier this year M is a month later this year M is this month This is the code I have for it so far - import java.util.*; import java.time.*; public class PastPresentFuture { public static void main (String args[]) { LocalDate today = LocalDate.now(); LocalDate enteredDate; int mo, da, yr; int todayMo, todayDa, todayYr; Scanner input = new Scanner(System.in); System.out.print("Enter a month >> "); mo = input.nextInt(); System.out.print("Enter a day >> "); da = input.nextInt(); System.out.print("Enter a year (four digits) >> "); yr = input.nextInt(); } }arrow_forwardJava. Write an application that accepts a word from a user and converts it to Pig Latin. If a word starts with a consonant, the Pig Latin version removes all consonants from the beginning of the word and places them at the end, followed by ay. For example, cricket becomes icketcray. If a word starts with a vowel, the Pig Latin version is the original word with ay added to the end. For example, apple becomes appleay. If y is the first letter in a word, it is treated as a consonant; otherwise, it is treated as a vowel. For example, young becomes oungyay, but system becomes ystemsay. For this program, assume that the user will enter only a single word consisting of all lowercase letters.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_forward
- In the Java programming language, write a program that opens a 400x200 window with two 200x200 buttons. One button says "Close" - which closes the program, and on the other the number "16". Each time you press this button, the number is halved until 1. When 1 is reached the button does not change anymore.arrow_forwardWrite a java program named Fibonacci that prints the Fibonacci sequence of numbers. The first two numbers in the Fibonacci sequence are 1. Every other number in the sequence is the sum of the two previous numbers. Your program should prompt the user to enter a limit; the program will stop when the current number in the sequence is greater than or equal to this limit. Here's what the user will see when the program is executed: This program prints the Fibonacci sequence Enter a limit on the largest number to be displayed: 50 1 1 2 3 5 8 13 21 34arrow_forwardPlease use JAVA GRAPHICS to create a card game in which the dealer shuffles the deck and deals 13 cards to the player. The player sorts her hand and says whether it includes the King of Hearts. Repeat 4 times so all the cards are dealt eventually. Internally, the player should return true or false without writing to the console. In response, the dealer should write on the console, "You won!" or "You loose again."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