-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNumericTypes.java
64 lines (54 loc) · 2.01 KB
/
NumericTypes.java
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
/**
This program demonstrates how numeric types and operators behave in Java
*/
//TASK #2 Add import statement here to use the Scanner class
//TASK #2 (Alternate) Add import statment to use JOptionPane class
public class NumericTypes
{
public static void main (String [] args)
{
//TASK #2 Create a Scanner object here (not used for alternate)
//identifier declarations
final int NUMBER = 2 ; // number of scores
final int SCORE1 = 100; // first test score
final int SCORE2 = 95; // second test score
final int BOILING_IN_F = 212; // freezing temperature
int fToC; // temperature in celsius
double average; // arithmetic average
String output; // line of output to print out
//TASK #2 declare variables used here
//TASK #3 declare variables used here
//TASK #4 declare variables used here
// Find an arithmetic average
average = SCORE1 + SCORE2 / NUMBER;
output = SCORE1 + " and " + SCORE2 + " have an average of "
+ average;
System.out.println(output);
// Convert Fahrenheit temperatures to Celsius
fToC = 5/9 * (BOILING_IN_F - 32);
output = BOILING_IN_F + " in Fahrenheit is " + fToC
+ " in Celsius.";
System.out.println(output);
System.out.println(); // to leave a blank line
// ADD LINES FOR TASK #2 HERE
// prompt the user for first name
// read the user's first name
// prompt the user for last name
// read the user's last name
// concatenate the user's first and last names
// print out the user's full name
System.out.println(); // to leave a blank line
// ADD LINES FOR TASK #3 HERE
// get the first character from the user's first name
// print out the user's first initial
// convert the user's full name to all capital letters
// print out the user's full name in all capital letters
System.out.println(); // to leave a blank line
// ADD LINES FOR TASK #4 HERE
// prompt the user for a diameter of a sphere
// read the diameter
// calculate the radius
// calculate the volume
// print out the volume
}
}