Java Programming, Loose-Leaf Version
9th Edition
ISBN: 9781337685900
Author: FARRELL, Joyce
Publisher: Cengage Learning
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.
in Java
Write a program that establishes two savings accounts with saver1 having account number10002 with an initial balance of $2,000, and saver2 having account 10003 with an initialbalance of $3,000. Set a common rate of interest at 5% per year. At the end of each month,update the balance by adding one month’s interest to the balance, so that the balancecompounds monthly. Print an output that displays the month number and the account numberand the balance for each of the two accounts. Use month 0 to display the initial balances, month1 to display the balances after the first month’s interest, and so on. At the end of the year,display the total balance for both accounts combined, like this:Output:Monthly balances for one year with 0.05 annual interest:Month Account # Balance Account # Balance----- --------- ------- --------- ------- 0 10002 2000.00 10003 3000.00 1 10002 2008.33 10003 3012.50 2 10002 2016.70 10003 3025.05 3 10002 2025.10 10003 3037.66 4 10002 2033.54 10003 3050.31 5…
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.
Chapter 5 Solutions
Java Programming, Loose-Leaf Version
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
- Java:arrow_forwardCreate 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.arrow_forwardThis needs to be done in Java! A palindrome is a sequence of characters that reads the same backward as forward. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 4554, and 11611. Write an application that reads in a five-digit integer and determines whether it’s a palindrome. If the number is not five digits long, display an error message and allow the user to enter a new value. Algorithm: Create two variables number and digits Capture the 5 digit number. Check If the number is not 5 characters long, display a message Use: while (digits != 5) Use if else statements: if (number < 100000) Set digits to 5 if > 9999 If not display statement letting the user know to enter correct 5 digit number Separate each digit: int digit1 = number / 10000; int digit2 = number % 10000 / 1000; int digit4 = number % 10000 % 1000 % 100 / 10; int digit5 = number % 10000 % 1000 % 100…arrow_forward
- 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_forwardTask 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_forward
- Please 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_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
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