COLLAGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT : SOFTWARE ENGINEERING
STUDENTS NAME ID
1) Gurmesa Fikadu 0382
2) Edan Bazezew 0274
1|Page
1. Write a java program which find the average, maximum, minimum and
sum of three numbers given by the users.
import java.util.Scanner;
public class JavaApplication3{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter First Number: ");
float a = in.nextInt();
System.out.print("Enter Second Number: ");
float b = in.nextInt();
System.out.print("Enter Third Number: ");
float c = in.nextInt();
float sum=a+b+c;
float avg=sum/3;
float max = Math.max(a, b);
max = Math.max(max, c);
float min = Math.min(a, b);
min = Math.min(min, c);
System.out.println("Average number = " + avg);
System.out.println("the sum number is = " + sum);
System.out.println("maximum Number = " + max);
System.out.println("minimum Number = " + min);
2|Page
2. Write a java program which accepts 10 constative integer numbers and
compute square root and power of 2 of the number.
import java.util.Scanner;
class JavaApplication4 {
public static void main( String args[] ) {
Scanner in = new Scanner(System.in);
System.out.print("Enter First Number: ");
float no1 = in.nextInt();
System.out.print("Enter Second Number: ");
float no2 = in.nextInt();
System.out.print("Enter Third Number: ");
float no3 = in.nextInt();
System.out.print("Enter fourth Number: ");
float no4 = in.nextInt();
System.out.print("Enter fiveth Number: ");
float no5 = in.nextInt();
System.out.print("Enter sixth Number: ");
float no6 = in.nextInt();
System.out.print("Enter seventh Number: ");
float no7 = in.nextInt();
System.out.print("Enter eightth Number: ");
float no8 = in.nextInt();
3|Page
System.out.print("Enter nineth Number: ");
float no9 = in.nextInt();
System.out.print("Enter tenth Number: ");
float no10 = in.nextInt();
getResults(no1);
getResults(no2);
getResults(no3);
getResults(no4);
getResults(no5);
getResults(no6);
getResults(no7);
getResults(no8);
getResults(no9);
getResults(no10);
static void getResults(float number){
System.out.println("\nFor "+number);
System.out.println("The power of 2 is "+Math.pow(number, 2));
System.out.println("The square root is "+Math.sqrt(number));
4|Page
3. Create A Class Group_ Name that has variables FullName, IDNO, Gender
and Departement of public. Write the java program that prints your group
information.
public class Group_Name2{
private String fullName;
private int idNo;
private String gender;
private String department;
public Group_Name2(String fullName, int idNo, String gender, String
department) {
this.fullName = fullName;
this.idNo = idNo;
this.gender = gender;
this.department = department;
public String getFullName() {
return fullName;
public void setFullName(String fullName) {
5|Page
this.fullName = fullName;
public int getIdNo() {
return idNo;
public void setIdNo(int idNo) {
this.idNo = idNo;
public String getGender() {
return gender;
public void setGender(String gender) {
this.gender = gender;
public String getDepartment() {
return department;
6|Page
public void setDepartment(String department) {
this.department = department;
public static void main(String[] args) {
Group_Name2 student1 = new Group_Name2("Gurmesa Fikadu", 382,
"Male", "Software Engineering");
Group_Name2 student2 = new Group_Name2("Edan Bazezew", 274,
"Female", "Software Engineering ");
System.out.println("FullName IDNO Gender Department");
System.out.println(student1.getFullName() + " " + student1.getIdNo() + "
" + student1.getGender() + " " + student1.getDepartment());
System.out.println(student2.getFullName() + " " + student2.getIdNo() + "
" + student2.getGender() + " " + student2.getDepartment());
4. Write a java program that accepts five student name, course name, score
and grade point from user and displays the information.
import java.util.Scanner;
public class JavaApplication7{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
7|Page
String[] names = new String[5];
String[] courses = new String[5];
int[]score = new int[5];
String[] gradePoint = new String[5];
for(int i=0;i<5;i++){
System.out.println("Enter student name:");
names[i]=input.nextLine();
System.out.println("Enter course name:");
courses[i]=input.nextLine();
System.out.println("Enter score:");
score[i]= input.nextInt();
if(score[i]>=90){
gradePoint[i]="A";
}else if(score[i]>=80){
gradePoint[i]="B";
}else if(score[i]>=70){
gradePoint[i]="c";
}else if(score[i]>=60){
gradePoint[i]="D";
}else{
gradePoint[i]="F";
8|Page
}
System.out.println("Student Name\t Course Name\t Score\t Grade Point");
for(int i=0;i<5;i++){
System.out.println( names[i]+"\t"+courses[i]+"\t\t"+score[i]+"\t\t"+gradePoint[i]);
5. Write in detail Abstract window toolkit(AWT), Java virtual machine(JVM),
Java Applet and Java swing with their purpose in software development
with their pros and cons.
Abstract Window Toolkit (AWT):
AWT is a set of classes and APIs provided by Java that allows developers to create and manage
graphical user interfaces (GUI) in Java applications. It provides a set of tools that allow users to
interact with the program through icons, menu options, and other graphical elements. AWT is
platform-dependent, which means that its appearance and behavior can vary depending on the
operating system it is run on. The AWT package includes classes such as Button, Label,
TextField, and TextArea which contain basic functionalities for creating simple desktop
applications.
Pros:
- AWT is built-in Java library which means it is readily available for any Java developer
- AWT is lightweight and easy to use
- It provides easy layout managers that can help structure GUI components in a
programmer- friendly way
Cons:
- AWT is platform-dependent, which may cause inconsistency in the look and feel of the
application
- Limited functionality and UI components compared to other libraries such as Java Swing
9|Page
Java Virtual Machine (JVM):
JVM is a virtual machine that interprets compiled Java bytecode and performs its functions. It is
responsible for executing Java programs regardless of the hardware and operating system in
use. The JVM is the cornerstone of the Java platform and provides a secure way to execute Java
code.
Pros:
- Platform-independent which means that Java code compiled on one platform can run on any
platform with a JVM installed
- Provides automatic memory management which relieves the programmer of the burden of
freeing up memory allocations
- Performs just-in-time (JIT) compilation which provides faster execution speed.
Cons:
- JVM can be resource-intensive leading to higher hardware requirements compared to other
platforms
- Some operating systems do not have a JVM installed by default
Java Applet:
Java Applet is a program that runs in a web browser and is used to create dynamic and
interactive web content. Applet is a lightweight Java program that is used mainly for interactive
graphics and multimedia presentations. They are similar to a standard desktop application but
are designed to run within the web browser.
Pros:
- Provides interactive and dynamic web content to the user
- Can be integrated with different web technologies such as HTML and JavaScript
Cons:
- Security concerns as applets can access local resources
10 | P a g e
- The popularity of applets has reduced in recent years due to the rise of HTML5 and browser
plugins being phased out.
Java Swing:
Java Swing is a set of graphical user interface (GUI) components that provide a modern UI and
greater functionality than the AWT. Swing is based on the Model-View-Controller (MVC) design
pattern and provides a set of advanced UI components for modern desktop applications.
Pros:
- Provides advanced UI components such as tables, graphs, and charts which are not in the AWT
- Platform-independent and provides a consistent look and feel of the application across
platforms.
Cons:
- Swing is heavier than AWT, and its performance can be slower in some cases.
- Programming with Swing can be more verbose and complex than AWT.
In conclusion, every technology in software development has its strengths and weaknesses,
and the choice of technology depends on the specific task at hand, the requirements, and
constraints of the project. However, in general, Java developers can leverage the strength of
AWT for basic and lightweight desktop applications while Swing can be used to create more
complex and modern desktop applications. JVM provides the necessary virtual machine to
execute Java code while Java Applets can be used to create dynamic and interactive web
content.
11 | P a g e