This project will allow you to play a bit with scanners, strings, and conditionals. You will have to implement three tasks, available as separate .java files in the CVS repository for the project. Below are the details for these tasks.
For this task you will have to write code that asks a user to input two integers. Your code will have to then print the maximum of the two integers. For an extra challenge think about how you would implement it without using a conditional statement.
For this task you will have to write code that asks a user to enter a geographic coordinate (either a latitude or a longitude) in the format:
ddd mm ss [EWNS]
where ddd is an integer representing the number of degrees
mm is an integer representing the number of minutes
ss is an integer representing the number of seconds
[EWNS] is a character that can only take the values E, W, N, S corresponding to the respective hemisphere.
Your code must then output a decimal representation of the coordinate following the conventions:
- Western longitudes and Southern latitudes are represented as negative numbers.
- The decimal representation is simply the sum of the degrees, minutes divided by 60 and seconds divided by 3600 (see more details here: http://astro.unl.edu/naap/motion1/tc_units.html ).
If the numbers entered do not represent a correct latitude or longitude number you must output "ERROR".
For example, the input
170 3 27 W
while the input
120 40 15 N
as latitudes cannot exceed 90 degrees.
Task 3 (ungraded challenge problem)
For this task you must ask the user for two strings, then output the string "YAY" if the strings input by the user are circular rotations of each other and the string "BOO" otherwise. An example of strings that are circular rotations of each other is:
To really meet this challenge, you must solve the problem using conditionals and String methods only, without relying on iteration.