CS173: Intro to Computer Science - Introduction to Boolean Expressions (3 Points)
Developed by Professor Tralie and Professor Mongan.Exercise Goals
The goals of this exercise are:- To become familiar with the basic structure of a Java program
- To write a Java statement
- To declare a variable
- To manipulate a variable with arithmetic statements
- To write a compound boolean expression to verify a numeric range
- To check the value of an imprecise floating point value
- To explain that a floating point value is represented imprecisely with a discrete binary representation
Enter your Ursinus netid before clicking run. This is not your ID number or your email. For example, my netid is wmongan
(non Ursinus students can simply enter their name to get this to run, but they won't get an e-mail record or any form of credit).
Netid |
Driver.java
public class Driver {
public static void main(String[] args) {
/* Don't change these! */
float diameter = 6.5;
float pi = 3.14159;
/* TODO: Declare a floating point variable circumference,
and set it equal to pi * the diameter */
/* TODO: Print the circumference of this circle */
/* The true circumference is 20.420335, which you can verify on your calculator.
But you might get something slightly different here! Why? */
/* TODO: Declare a boolean variable called isApproximatelyEqual, whose value is
true if the circumference is "approximately equal" to 20.420335, by checking
if it is greater than a nearby value like 20.42 and smaller than a nearby
value like 20.43. */
/* I'll print the value for you - don't change this! */
System.out.println(isApproximatelyEqual);
}
}
Driver.main(null);