Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 2-Write a Program Submit a program called: Dates.java Talib wants to create a program that allows users to enter today's date (or any other
Problem 2-Write a Program Submit a program called: Dates.java Talib wants to create a program that allows users to enter today's date (or any other date) in either decimal or binary. The input should be in the form MM/DD or MM-DD and be followed by a b (for binary) or a d (for decimal). The program should then convert the date from the base entered into the other base. For example if they enter the date in decimal, the program should return the date in binary (see the following sample run) The program should continue until quit is entered. It should also let the user know if they entered the wrong format (see the following sample run) You should use the methods we created in class (in ClassCode15-you can just copy these methods directly into your program) since most of the conversion work between bases has been done for you in these methods. In addition, you may find it useful to create other methods to further help you create your program. You may also use methods (or variations of methods) we created in other classes. Methods used in ClassCode15: String DecToBinary(int userlnput) String buildNum(int num) int BinaryToDec(int userInput) int valueToAdd(char c, int exp) Create yourself: Feel free to create any methods that help you: a method to determine which base the user entered, a method to do the actual date conversion etc. Sample Run: Enter today's date, month followed by day: (b-binary d-decimal) 08/06 Wrong format. Enter again. **Enter today's date, month followed by day: (b-binary d-decimal) 08/06 d Date in binary: 1000/110 *Enter today's date, month followed by day: (b-binary d-decimal) 09-15 Wrong format. Enter again. *Enter today's date, month followed by day: (b-binary d-decimal) 09-15 d Date in binary: 1001/1111 ** *Enter today's date, month followed by day: (b-binary d-decimal) 1000/110 b Date in decimal: 08/06 Enter today's date, month followed by day: (b-binary d-decimal) quit Bye :)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started