0% found this document useful (0 votes)
26 views4 pages

OOP EnablingAssessment 2CAS

The document provides Java programming problems and examples to input and output data, perform conversions and comparisons, and display patterns based on user input. It includes problems to get student details, currency conversions, finding the largest of three numbers, and printing patterns of stars, zeros and Xs based on a user-provided number.

Uploaded by

rohmantiq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views4 pages

OOP EnablingAssessment 2CAS

The document provides Java programming problems and examples to input and output data, perform conversions and comparisons, and display patterns based on user input. It includes problems to get student details, currency conversions, finding the largest of three numbers, and printing patterns of stars, zeros and Xs based on a user-provided number.

Uploaded by

rohmantiq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

De La Salle University - Dasmariñas 1

CEAT – Engineering Department

T-CPET221LA – Introduction to Computational Thinking


ENABLING ASSESSMENT 2: Java Programming
Name: ____________________________________________________________
Year and Section: _______________________ Date: _______________________ Rating:

OBJECTIVES
ü Perform Java I/O operations
ü Apply conditional and loop structure in Java programming
ü Provide problem solutions through Java programming

INSTRUCTION: Provide the Java code as your analysis and solution of the following problems.

1. Input your complete student details and then display it. (Student name, Course and Student #)
2. public class seta7 {
3.
4. public static void main(String[] args) {
5. Scanner sc = new Scanner(System.in);
6.
7. System.out.println("Enter your name: ");
8. String name = sc.nextLine();
9.
10. System.out.println("Enter your course: ");
11. String course = sc.nextLine();
12.
13. System.out.println("Enter your student number: ");
14. String studentNumber = sc.nextLine();
15.
16. System.out.println("\nName: " + name);
17. System.out.println("Course: " + course);
18. System.out.println("Student Number: " + studentNumber);
19. }
20.
21. }

22. Search in the internet the exchange rate of PHP vs USD and SGD. In your program, input a PHP peso and
display its equivalent USD and SGD values. Display also the source of your conversion rate.
23. public static void main(String[] args) {
24. Scanner sc = new Scanner(System.in);
25.
26. System.out.println("Enter PHP amount: ");
27. double php = sc.nextDouble();
28.
29. double usd = php * 0.018;
30. double sgd = php * 0.024;
31.
32. System.out.println("\nPHP to USD: " + usd + "$");
33. System.out.println("PHP to SGD: " + sgd + "S$");
T-CPET221LA
Object Oriented Programming
De La Salle University - Dasmariñas 2
CEAT – Engineering Department

34. System.out.println("SGD Source: https://g.co/kgs/sQPCKy");


35. System.out.println("\nUSD Source: https://g.co/kgs/jG96pV");
36.
37. }
38.
39. }

40. Input three numbers and display the largest among the three.
41. public static void main(String[] args) {
42. Scanner sc = new Scanner(System.in);
43.
44. System.out.println("Enter first number: ");
45. int first = sc.nextInt();
46.
47. System.out.println("Enter second number: ");
48. int second = sc.nextInt();
49.
50. System.out.println("Enter third number: ");
51. int third = sc.nextInt();
52.
53. if (first > second && first > third) {
54. System.out.println("\n" + first + " is the largest number.");
55. } else if (second > first && second > third) {
56. System.out.println("\n" + second + " is the largest number.");
57. } else if (third > first && third > second) {
58. System.out.println("\n" + third + " is the largest number.");
59. } else {
60. System.out.println("\nThere is no largest number.");
61. }
62.
63. }
64.
65. }

66. Display like the figure where the number = 5.


67. public static void main(String[] args) {
68. Scanner sc = new Scanner(System.in);
69.
70. System.out.println("Enter number: ");
71. int number = sc.nextInt();
72.
73. System.out.println();
74.
T-CPET221LA
Object Oriented Programming
De La Salle University - Dasmariñas 3
CEAT – Engineering Department

75. for (int i = 0; i < number; i++) {


76. for (int j = 0; j < number; j++)
77. System.out.print("*");
78. System.out.println();
79. }
80. }
81.
82. }
83.

84. Display like the figure where the value of the number is an input value. (In this example, the value of of input
number is 4.

public static void main(String[] args) {


Scanner sc = new Scanner(System.in);

System.out.println("Enter number: ");


int number = sc.nextInt();

System.out.println();

for (int i = 0; i < number; i++) {


if (i % 2 == 0) {
for (int j = 0; j < number; j++)
System.out.print("0");
System.out.println();
} else {
for (int j = 0; j < number; j++)
System.out.print("X");
System.out.println();
}

T-CPET221LA
Object Oriented Programming
De La Salle University - Dasmariñas 4
CEAT – Engineering Department

T-CPET221LA
Object Oriented Programming

You might also like