Learning Activity 3: Java Expressions
Objectives
Evaluate result of different expressions
Practice using the Java syntax for variables, expressions and statements.
Instructions
Check version
We will evaluate the following expressions using a Java program:
12 / 5
12.0 / 5
12 / 5 + 8 / 4
3 * 4 + 15 / 2
42 % 5 + 3 % 16
Write Java program to evaluate the expressions given above and print their results. Below are additional requirements on the Java program:
The program should be named Expressions.java and should contain the main class Expressions.
The program should declare variables within the application method (publlic static void main(String[] ags) method).
Each expression should be evaluated within the application method and assigned to a declared variables.
The program should print a statement for each of the expressions along with its result in a new line.
Here is a sample output the program should generate for expression 10/2:
The result of the expressions 10/5 is 2
Plus version
There is no plus version for this Learning Activity.
Submission
Submit the Java source file (.java file) of your application.
Learning ACtivity 3-Java Expressions.pages/preview.jpg Learning ACtivity 3-Java Expressions.pages/preview-web.jpg Learning ACtivity 3-Java Expressions.pages/preview-micro.jpg Learning ACtivity 3-Java Expressions.pages/Index.zip Index/Document.iwa Index/ViewState.iwa Index/CalculationEngine.iwa Index/DocumentStylesheet.iwa Index/AnnotationAuthorStorage.iwa Index/DocumentMetadata.iwa Index/Metadata.iwa Learning ACtivity 3-Java Expressions.pages/Metadata/DocumentIdentifier A7DDCED6-5918-424E-8562-666313AE4EDB Learning ACtivity 3-Java Expressions.pages/Metadata/BuildVersionHistory.plist Template: Blank (2015-09-16 11:13) M5.6.2-2573-1 Learning ACtivity 3-Java Expressions.pages/Metadata/Properties.plist