Workshop #1: Foundations of Java Language: Learning Outcomes

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Workshop #1: Foundations of Java language

Learning Outcomes:

Upon successful completion of this workshop, you will have demonstrated the abilities
to:

 Practice basic Java language syntax and semantics to write Java programs.
 Use concepts such as variables, conditional and iterative execution methods.
 Compile and run a program.
 Describe to your instructor what you have learned in completing this workshop.

Requirements:

Part1: [3 points]

Write a Java program that will accept a matrix of integers then this matrix will be printed out and
sum of values and average of values are printed also.

The user interface may be:


Enter number of rows: 2
Enter number of columns: 3
Enter the matrix
m[0][0]=1
m[0][1]=2
m[0][2]=3
m[1][0]=4
m[1][1]=5
m[1][2]=6
Matrix inputted:
123
456
Sum: 21
Average: 3.5

Hint: Use System.out.format("%3d", n);

Step by step workshop instructions:

- Initializing NetBeans and create a new project named “workshop1”

1
- Create a class named “part1.java”

- In the class “Part1.java”, you type:

Task 1: input the matrix

2
- To run the code, click the right mouse and choose “run file”
Task 2: get sum of values
- You will add the code to “Part1.java”

Task 3: get average of values

- You will add the code “System.out.println("Average:" +(float)sum/(rows*cols));” to “Part1.java”

Review criteria
Upon completion of the workshop, your submission will be reviewed based on the following criteria:

- Input the matrix successfully [1 point]

3
- Get sum [1 point]
- Get average [1 point]

Part 2: [3 points]

Write a Java program that will accept two float numbers and an operator (+-*/) then the program
will print out the result of the specified expression that bases on the inputted operator.

The user interface may be:


Input the number 1: 4
Input the number 2: 5
Input the operator: +
the result of 4+5=9

Step by step workshop instructions:


- In the project above, you create a new class named “Part2.java” and add the code:

- You must add your code to get the result when user inputs another operator

Part 3 [4 points]

Write a Java program that will accept the list of student name, convert all names to uppercase
and then the program will print out the list of student name.

Step by step workshop instructions:


- you create a new class named “Part3.java” and add the code:

4
5

You might also like