-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCh09Ex1_3.java
More file actions
78 lines (63 loc) · 2.06 KB
/
Ch09Ex1_3.java
File metadata and controls
78 lines (63 loc) · 2.06 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
/**
Chapter 9 - Variables and Assignment Statements
Programming Exercises 1-3
@author TODO Your Name
@version TODO Date
@author Period - TODO Your Period
@author Assignment - Ch09Ex1_3
@author Sources - TODO list collaborators
*/
public class Ch09Ex1_3
{
public Ch09Ex1_3()
{ }
/**
Payroll method
*/
public void payroll()
{
long hoursWorked = 40;
double payRate = 10.0, taxRate = 0.10;
System.out.println( "Hours Worked: " + hoursWorked );
System.out.println( "pay Amount : " + ( hoursWorked * payRate ) );
System.out.println( "tax Amount : " + ( hoursWorked * payRate * taxRate ) );
}
/**
Computes value of the quadratic
3*X^2 -8*X + 4
for several values of X. The program uses a double precision variable X,
assigns a value to it, and writes statement that computes a value for
the quadratic and stores the result in another double precision variable.
Finally the result is written out in the following form:
At X = 4.0 the value is 20.0
*/
public void valueOfAQuadratic()
{
// Your code goes here
}
/**
Modify of the ValueOfAQuadratic() method so that one run of the method
will evaluate and write out the value of the quadratic for three
different values of X: 0.0, 2.0, and 4.0 (or any three chosen values.)
The method is written using only two variables, called x and value.
*/
public void reassign()
{
// Your code goes here
}
/**
Testing method: instantiates a Ch09Ex1_3 object and
then invokes each method
@param args command line parameters (not used)
*/
public static void main( String[] args )
{
Ch09Ex1_3 exercise = new Ch09Ex1_3();
exercise.payroll();
System.out.println();
exercise.valueOfAQuadratic();
System.out.println();
exercise.reassign();
System.out.println();
}
}