On this lab (and all future work in this course), the name of the files you submit and the name of the classes they contain must match. That is, the file Foo.java
must contain (only) the class Foo
.
-
Create a Java class named
Circle
(in a fileCircle.java
) that calculate the area of a circle for the user. Here are two examples of what the program should look like when you run it:Enter the radius of the circle: 10
The area of the circle is 314.16.Enter the radius of the circle: 39.43
The area of the circle is 4884.32374584.Enter the radius of the circle: -10
Sorry, I can't do a negative radius.Use the formula 3.1416r2 to calculate the area.
-
We want to write a program that counts for the user. It should ask them where to start, end, and what it should count by:
Start at: 3
End at: 10
Count by: 2
3 5 7 9Start at: 100
End at: 120
Count by: 5
100 105 110 115 120- Create a class
Count1
, and write this program using afor
loop. - Create a class
Count2
, and write this program using awhile
loop.
- Create a class
-
Create a class
AlphaChars
that contains these functions:isAlpha
, that takes a single character as its argument, and returnstrue
if the characters is a letter (a–z or A–Z), orfalse
otherwise. The function declaration should be:public static boolean isAlpha(char c) { … }
isAllAlpha
, that takes a string as its argument, and returnstrue
if all of the the characters in the string are letters (a–z or A–Z), orfalse
otherwise. The function declaration should be:public static boolean isAllAlpha(String s) { … }
The class should contain no
main
function; you'll have to create another class to test it. -
Create a text file named
time.txt
. In it, indicate how long it took you to complete this lab exercise.
When you're done, create a ZIP file containing all of the files you created for this lab and submit it with the submission server.