-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCh08Exercises.java
More file actions
80 lines (67 loc) · 1.84 KB
/
Ch08Exercises.java
File metadata and controls
80 lines (67 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/**
Chapter 08 - Primitive Data Types
Programming Exercises 1-4
@author TODO Your Name
@version TODO Date
@author Period - TODO Your Period
@author Assignment - ch8_PrimitiveDataTypes
@author Sources - TODO list collaborators
*/
public class Ch08Exercises
{
public Ch08Exercises()
{ }
/**
A method to explore the short data type
*/
public void shortEg()
{
int value = 35000;
System.out.println("A short: " + value);
}
/**
A method to explore the double data type
*/
public void doubleEg()
{
double value = 8;
System.out.println("A double: " + value);
}
/**
The following method explores the primitive data type double.
This program computes and writes out the value of exp(32).
This is the base of natural logarithms "e" raised to the power 32.
(Don't worry much about this. The point of the program is not the
math but the floating point numbers.)
*/
public void doubleCrash()
{
double value = 11.1;
System.out.println("e to the power value: " + Math.exp( value ) );
}
/**
A method to explore the char data type
*/
public void charEg()
{
char ch = 'P' ;
System.out.println("A char: " + ch );
}
/**
Testing method: instantiates a Ch08Ex1_4 object and
then invokes each method
@param args command line parameters (not used)
*/
public static void main (String[] args )
{
Ch08Exercises exercise = new Ch08Exercises();
exercise.shortEg();
System.out.println();
exercise.doubleEg();
System.out.println();
exercise.doubleCrash();
System.out.println();
exercise.charEg();
System.out.println();
}
}