Java Exercises
Java Exercises
ICT Department
EXERCISES
1
Sample output
Enter Height of trapezoid: 6
Enter Base one value: 10
Enter Base two value: 5
Area is: 45.0
2
4. Write a Java program which accepts the user's first and last name and
print them in reverse order with a space between them.
Sample Output
Input your First Name : Sam
Input your Last Name : Mkhwanazi
Hello Mkhwanazi Sam
5. Write a Java program that will accept the base and height of a triangle
and compute the area.
Area of a triangle
A triangle is a polygon with three edges and three vertices. It is one of the
basic shapes in geometry. A triangle with vertices A, B, and C is denoted
triangle ABC.
Attributes
Methods
3
- Overloaded constructors
Code a class called StudentTester (the application-(Java Main Class)) to test the
Student class. Your application should perform the following functionalities:
- Get the inputs for all instance variables, see screenshot below
- Instantiate an object of the Student class
- Invoke calcSemesterMark() function from Student class and pass correct
parameters
- Print headings with correct tabs
- Invoke (call) the toString() method to display name, subject code, all tests
and calculated semester mark.
****************END EXERCISES******************