You are on page 1of 5

QUEZON CITY UNIVERSITY

COLLEGE OF COMPUTER STUDIES


INFORMATION TECHNOLOGY DEPARTMENT

CC103 – INTERMEDIATE PROGRAMMING


LABORATORY ACTIVITY # 1

NAME: _ SCORE PERCENTAGE

STUDENT NO:
YEAR/SECTION: _ ____
DATE:

INSTRUCTION:

A. “Data types”

Create a java program to convert temperature from Fahrenheit to Celsius degree.

Test Data

Input a degree in Fahrenheit:212


Expected output:
212.0 degree Fahrenheit is equal to 100.0 in Celsius

B. “Conditional statements”

Create a java program that accepts three (3) numbers from user and print the greatest number.

Test Data

1st number: 25
2nd number: 78
3rd number: 87

Expected output:
The Greatest number is : 87

C. “Arrays”

Create a java program that sum all the ten(10) elements of the arrays.

Test Data

Array elements are: 6 8 1 2 9 55 23 55 33 44

Expected output:

The sum of all elements are:236


QUEZON CITY UNIVERSITY
COLLEGE OF COMPUTER STUDIES
INFORMATION TECHNOLOGY DEPARTMENT

ASSESSMENT CRITERIA
CRITERIA ACTUAL
SCORE
Program Design 25
Program Execution 20
Specifications Satisfaction 20
Coding Style 15
Creativity 10
Total Score 100
QUEZON CITY UNIVERSITY
COLLEGE OF COMPUTER STUDIES
INFORMATION TECHNOLOGY DEPARTMENT

A. Source Code:
import java.util.Scanner;
import java.text.DecimalFormat;

public class Main {

private static final DecimalFormat df = new DecimalFormat("0.00");

public static void main(String[] args) {


Scanner input = new Scanner(System.in);
System.out.println("Input Fahrenheit:");
double fah = input.nextDouble();

fah = (fah - 32) * 5/9;

System.out.println(df.format(fah) + " celcius");


}
}

Screenshot:
QUEZON CITY UNIVERSITY
COLLEGE OF COMPUTER STUDIES
INFORMATION TECHNOLOGY DEPARTMENT

B. Source Code:
import java.util.Scanner;
public class Main {

public static void main(String[] args) {


Scanner input = new Scanner(System.in);

int[] compare = new int[3];

for(int i = 0; i < compare.length; i++){


System.out.println("Input a number:");
compare[i] = input.nextInt();
}
if (compare[0] > compare[1] && compare[0] > compare[2]){
System.out.println("The greatest number is:" + compare[0]);
}
else if(compare[1] > compare[0] && compare[1] > compare[2]){
System.out.println("The greatest number is:" + compare[1]);
}
else if(compare[2] > compare[0] && compare[2] > compare[1]){
System.out.println("The greatest number is:" + compare[2]);
}
else{
System.out.println("You entered the same number");
}
}
}Screenshot:
QUEZON CITY UNIVERSITY
COLLEGE OF COMPUTER STUDIES
INFORMATION TECHNOLOGY DEPARTMENT

C. Source Code:
import java.util.Scanner;

public class Main{


public static void main(String[] args) {
Scanner input = new Scanner(System.in);

int array[] = new int [10];


int sum = 0;

for(int i =0; i < array.length; i++){


System.out.println("Input number:");
array[i] = input.nextInt();
}

for(int i =0; i < array.length; i++){


sum += array[i];
}
System.out.println("The sum of all elements is: " + sum);
}
}

Screenshot:

You might also like