Welcome to lab 3!
If you have checkpoints from the last lab to show your instructor or TA, do so immediately. No credit will be given if you have not already completed the work, nor will credit be given after the first 10 minutes of this lab.
Work with a partner that you have not worked with before.
Our goal today is to acquaint ourselves with methods of the
Person A types. Make a
labs.lab03 package in your IntelliJ project.
Complete three of the following problems:
Circler, prompt the user for four numbers: an x-coordinate for point A, a y-coordinate for point A, an x-coordinate for point B, and a y-coordinate for point B. Print the parametric equation of the circle whose perimeter passes through these two points. The equation should follow this pattern:
(x - originX)^2 + (y - originY)^2 = radius^2For example, if point A is (0, 0) and point B is (1, 0), print the following equation:
(x - 0.5)^2 + (y - 0)^2 = 0.5^2Use
printfinstead of a messy concatenation.
Clamper, write a
mainmethod that asks the user for a single number. Clamp the number to the range [lo, hi] and print the result. That is, if the number is less than lo, print the number lo. If it is greater than hi, print the number hi. Otherwise, the number is already within the range and can be printed as is. Use
Math.maxto solve this. Do not use
ifstatements, even if you’re familiar with them. Do not prompt the user for lo and hi. You, the developer, should define them directly in the code according to your whimsy.
Range, prompt the user to enter a low number and a high number, both integers. Generate a random integer in that range, inclusively. Use only
Math.random, not the
Randomclass. Test your code with a small range, like 20 through 21, and make sure you see all numbers in this range.
Scannermethod call, and then magically prints out your username, which is the first letter of your first name followed by your complete last name, all lowercase. For example, if the user enters “Robin Steele”, the username is “rsteele”. In class
Usernamer, write a
mainmethod that accomplishes this task.
Ticker, prompt the user to enter two team names and two integer scores. Print them using a single call to
String.format) such that the team names are left-aligned to fill 15 columns and the scores are right-aligned to fill 4 columns, with a
|character separating the columns. For example:
Heffalumps | 17 Woozles | 9See this reference on the format string protocol.
Person B types.
Write a class
Crossworder that gets two words as input and prints one vertically and one horizontally so that they intersect. For example:
vertical: coffee horizontal: suffering c o suffering f e e
This problem is very open-ended. Solve it in a way that makes sense to you.