Comp3activities - These are my lecture notes in my respective course. Hope it helps! PDF

Title Comp3activities - These are my lecture notes in my respective course. Hope it helps!
Author Yanyan Domingo
Course Business Admnistration
Institution Western Philippines University
Pages 13
File Size 1.4 MB
File Type PDF
Total Downloads 144
Total Views 196

Summary

POLYTECHNIC UNIVERSITY OF THE PHILIPPINESSta. Mesa, ManilaName : Denise C. Fabregas Subject : ICT 2113 Section : DICT 2- 2Red means d pa sure and wala pang sagotActivity #1: One of the most powerful programming languages. Java Programming Language The first name of Java? OAK was the first name of Ja...


Description

POLYTECHNIC UNIVERSITY OF THE PHILIPPINES Sta. Mesa, Manila Name: Denise C. Fabregas Section: DICT 2-2

Subject: ICT 2113

Red means d pa sure and wala pang sagot Activity #1: 1. One of the most powerful programming languages. Java Programming Language 2. The first name of Java? OAK was the first name of Java. 3. Considered as the father of Java Programming Language? James Gosling is considered as the father of Java programming Language. 4. It is an abstract machine that enables your computer to run a java program ? Java Virtual Machine (JVM) 5. It is a software package that provides Java class libraries, along with Java Virtual Machine (JVM), and other components to run applications written in Java programming. JRE as the superset of JVM. Java Runtime Environment (JRE) 6. It is a software development kit to develop applications in Java. Java Development Kit (JDK) 7. What are the 4 principles of Java Programming? • Ease of use • Reliability • Security • Platform Independence Activity #2:

Instruction: On the space provided at the right column, write VALID if the given literal is valid. Otherwise, write the valid form. 1) 1.525

VALID

2) 60 mile/hour

6) 2100.00 7) 0.07

3) 80 %

.80

8) -20

4) “RITM”

VALID

9) “Computer”

5) ‘A’

VALID

10) 1/2

VALID VALID

VALID .50

1. Which of the following may be used as variable names in Java? Rate1, 1stPlayer, myprogram.java, long, TimeLimit, numberOfTimes Answer: long, numberOfTimes, 2. Can a Java program have two different variables with the names aVariable and avariable? Answer: YES 3. Give the declaration for a variable called count of type int. The variable should be initialized to zero in the declaration. Answer: int count = 0; 4. Give the declaration for two variables of type double. The variables are to be named rate and time. Both variables should be initialized to zero in the declaration. Answer: double rate = 0.0; double time = 0.0; 5. Write a declaration for two variables called miles and flowRate. Declare the variable miles to be of type int and initialize it to zero in the declaration. Declare the variable flowRate to be of type double and initialize it to 50.75 in the declaration. Answer: int miles = 0; double flowRate = 50.75; 6. Write a Java assignment statement that will set the value of the variable interest to the value of the variable balance multiplied by 0.08. Answer: interest = balance * 0.08; 7. Write a Java assignment statement that will set the value of the variable interest to the value of the variable balance multiplied by the value of the variable rate. The variables are of type double. Answer: double interest = balance * rate; 8. Write a Java assignment statement that will increase the value of the variable count by 3. The variable type is int. Answer: int count = count + 3; 9. Write a Java assignment statement that will decrease the value of the variable count by 5. The variable type is int. Answer: int count = count – 5; 10. Write a Java assignment statement that will compute the area of a rectangle. Answer: double b = 0.0; double h = 0.0; double area = b*h;

Activity #3:

1. Write a program to convert the input dollar (4) into its peso equivalent. Presume that one dollar is equivalent to 50.75. Then display the result on the screen.

2. Write a program to calculate the volume of a sphere. Then display the result. Use the following formula: vsphere = 4/3 π r3.

3. Write a program to compute the gross pay of a worker name Juan Dela Cruz given that Juan Dela Cruz worked for 40 hours at the rate of 215.75.

4. Write a program that will compute the sum and product of two input numbers.

5. Write a program that will compute the average grade of the student based on the three-grading system. Prelim 85, Midterm 93 and Final 87.

6. Write a program that will accept two numbers and then swap the arrangement of the two numbers

7. Write a program that will compute and output the time required to travel 5400 miles at a speed of 220 mph.

8. Write a program that will compute and display the area and perimeter of a rectangle. Formula: area = length * width and perimeter = 2(length + width)

9. Write a program that will convert the input number in feet to inches.

10. Mary deposited her money of 250000php at a bank. The bank gave her 12% for a term of 30 days. There is a 10% withholding tax to be deducted from the interest. a. Find her withholding tax b. Find the net interest, she will receive. Use the following formula: I = PRT where, I-interest, Pprincipal value, R-rate of Interest and T-time.

Activity #4:

1. Write a program that will check if the input number is POSITIVE or NEGATIVE. Consider 0 as positive number. Display the word POSITIVE or NEGATIVE.

2. Write a program that will input a number and will print “DIVISIBLE” if the input number is divisible by 5, otherwise print “NOT DIVISIBLE”

3. Write a program that will input numbers from 1 to 12 and will display the equivalent months of the year.

4. Write a program that checks the value of a variable called temperature. Then display the following messages depending on the value assigned to the temperature variable. Temperature Remarks Less than zero ICE Between 0 and 100 WATER Exceeds 100 STEAM

5. Write a program that will ask the user to input a character “m” or “f” and then it will display “HELLO SIR”, if the input is “m” otherwise “HELLO MADAM”

6. Write a program that will determine if the input number is ODD or EVEN. Display also the word ODD if the number is odd, EVEN if the number is even.

7. Write a program that will ask the user to input the age. If the age is less than 18 then display the message “YOU ARE NOT QUALIFIED TO VOTE”. If the age is 19 and above then display the message “YOU ARE QUALIFIED TO VOTE”.

8. Create a program that displays the total amount of money a company owes for a seminar. The seminar per person is based on the number of people the company registers. For example, if the company registers seven people, then the total amount owed by the company is P2800. If the user enters the number 0 or a negative number, the program should display an appropriate error message. Number of registrants 1–4 5 – 10 11 or more

9. Switch Statement program: Displaying a price. A program needs to display a price based on a product ID entered by the user. The valid product ID and their prices are shown below: Product ID Price 1 50.55 2 2 12.35 5 11.46 7 11.46 9 12.35 11 11.46

Fee per person P500 P400 P300

10. Write a program that will convert and display the Letter grade to its equivalent message. Assign an appropriate error message if the input letter is not from A to F. Letter grade Message A EXCELLENT B ABOVE AVERAGE C AVERAGE D BELOW AVERAGE F FAILED Activity #5:

1. Write a program to numbers from 1 to 10.

2. Write a program to calculate the sum of first 10 natural number.

print

3. Write a program that prompts the user to input a positive integer. It should then print the multiplication table of that number.

4. Write a program to find the factorial value of any number entered through the keyboard.

5. Two numbers are entered through the keyboard. Write a program to find the value of one number raised to the power of another. (Do not use Java built-in method)

6. Write a program that prompts the user to input an integer and then outputs the number with the digits reversed. For example, if the input is 12345, the output should be 54321.

7. Write a program that reads a set of integers, and then prints the sum of the even and odd integers.

8. Write a program that prompts the user to input a positive integer. It should then output a message indicating whether the number is a prime number.

9. Write a do-while loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The loop should ask the user whether he or she wishes to perform the operation again. If so, the loop should repeat; otherwise, it should terminate.

10. Write a program to print following:

i.

********** ********** ********** **********

ii.

* ** *** **** *****

iii.

iv.

* ** *** **** *****

* *** ***** ******* *********

v.

1 222 33333 4444444 555555555

vi.

1 212 32123 4321234 543212345...


Similar Free PDFs