File tree Expand file tree Collapse file tree 3 files changed +74
-0
lines changed Expand file tree Collapse file tree 3 files changed +74
-0
lines changed Original file line number Diff line number Diff line change
1
+ //print the word: "TOD" using asterisks
2
+ public class TOD {
3
+
4
+ public static void main (String [] args ) {
5
+ String tod = "*** *** **\n * * * * *\n * *** **\n " ;
6
+ System .out .println (tod );
7
+ }
8
+ }
Original file line number Diff line number Diff line change
1
+ import java .util .Scanner ;
2
+
3
+ public class Circle {
4
+
5
+ private Scanner keyboardInput ;
6
+ private int circleRadius ;
7
+ private int circleDiameter ;
8
+ private double circleCircumference ;
9
+ private double circleArea ;
10
+
11
+ public Circle () {
12
+ keyboardInput = new Scanner (System .in );
13
+ System .out .println ("Enter the Circle's radius" );
14
+ circleRadius = keyboardInput .nextInt ();
15
+ circleDiameter = circleRadius *2 ;
16
+ circleCircumference = circleDiameter *Math .PI ;
17
+ circleArea = circleRadius *circleRadius *Math .PI ;
18
+
19
+ }
20
+
21
+
22
+ @ Override
23
+ public String toString () {
24
+ return String .format ("Circle Details\n Diameter: %d" +
25
+ "\n Circumference: %.3f\n Area: %.3f" ,
26
+ circleDiameter , circleCircumference , circleArea );
27
+ }
28
+
29
+ public static void main (String [] args ) {
30
+ Circle circle = new Circle ();
31
+
32
+ System .out .println (circle .toString ());
33
+
34
+ }
35
+ }
Original file line number Diff line number Diff line change
1
+ import java .util .List ;
2
+ import java .util .ArrayList ;
3
+ import java .util .Scanner ;
4
+
5
+ public class SplitNumber {
6
+
7
+ private Scanner keyboardInput ;
8
+ private int testNumber ;
9
+
10
+ public SplitNumber () {
11
+ keyboardInput = new Scanner (System .in );
12
+
13
+ System .out .println ("Enter the number to split" );
14
+ testNumber = keyboardInput .nextInt ();
15
+
16
+ //get a number say 697
17
+ int highestPlaceValue = (int )Math .pow (10 , (Integer .toString (testNumber )).length ());
18
+ List <Integer > integers = new ArrayList <Integer >();
19
+
20
+ for (int i =1 ; i <highestPlaceValue ; i =i *10 ) {
21
+ int temp = testNumber /10 ;
22
+ integers .add (0 , testNumber %10 );
23
+ testNumber = temp ;
24
+ }
25
+ System .out .println (integers );
26
+ }
27
+
28
+ public static void main (String [] args ) {
29
+ SplitNumber numberSplit = new SplitNumber ();
30
+ }
31
+ }
You can’t perform that action at this time.
0 commit comments