OOP EnablingAssessment 2CAS
OOP EnablingAssessment 2CAS
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
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. }
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.
System.out.println();
T-CPET221LA
Object Oriented Programming
De La Salle University - Dasmariñas 4
CEAT – Engineering Department
T-CPET221LA
Object Oriented Programming