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

Module 2

Computer Programming 1 w/ Lab

Task 1

1. Create a flowchart on the conditional statement given on the program code on IF-ELSE
Activity. Show the Final Output of the Code.
Final Output:

Task 2
1. Examples and Scenario to be given must be appropriate on each Loop.
1. FOR LOOP

for(int i = 0; i < 10; i++)


{
System.out.println("*");
}

2. FOR EACH LOOP


String[] name = {"Rommela ","Rommel ","Rejean ","Rencee ", "Renzo ", "Ronan "};

for(String item: name)


{
System.out.println(item);
}

3. WHILE LOOP
int i=1;
while(i<=5){
System.out.println(i);
i++;
}

4. DO WHILE LOOP
int i=1;
do{
System.out.println(i);
i++;
}while(i<=10);

Task 3

1. Given the following codes. Create flowchart on the following:


a. Example No. 1
b. Example No. 2
c. Example No. 3
2. Explain how continue statement works.

The continue statement will re-evaluate the condition immediately and restart the loop without
running the code after the continue statement.

JAVA PROGRAM - INPUTS


SOURCE CODE:

package com.ntc.inputs;

import java.util.Scanner;

public class JavaInputs {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.print("Enter your Full Name :");


String fullname = sc.nextLine();
System.out.print("Enter your Address :");
String address = sc.nextLine();
System.out.print("Enter your Contact number :");
String contactno = sc.nextLine();
System.out.print("Enter your Favorite Sports :");
String sports = sc.nextLine();
System.out.print("Enter your Favorite Movie :");
String movie = sc.nextLine();
System.out.print("Enter your Favorite Food :");
String food = sc.nextLine();

System.out.println("\nHello " + fullname + " of " + address);


System.out.println("Your Contact Number is " + contactno);
System.out.println("You love playing " + sports);
System.out.println("You love to watch " + movie + " while eating your favorite "
+ food);

SAMPLE OUTPUT:

You might also like