// This time I try to follow the lead from "Java Fundamental" video, part 1-3.
// Written a number comparison program in Java and C
- // Comparison in Java
- import java.util.Scanner;
- public class Comparison
- {
- public static void main(String args[])
- {
- Scanner input = new Scanner(System.in);
- // create a new Scanner call 'input' and using System.in method.'Yet to be comfirmed.'
- int n1, n2;
- // Display tips and assign value from input to n1 and n2
- System.out.print("First Number: ");
- n1 = input.NextInt();
- System.out.print("Second Number: ");
- n2 = input.NextInt();
- if (n1 > n2)
- {
- System.out.printf("%d is larger than %d. /n", n1, n2);
- } else if (n1 == n2)
- {
- System.out.printf("They are equal. /n");
- } else
- {
- System.out.printf("%d is less than %d. /n", n1, n2);
- }
- }
- }
- // Number Comparision Program
- // Written in C by R.Wong
- #include <stdio.h>
- int main(void)
- {
- int n1, n2;
- printf("First Nubmer: ");
- scanf("%d", &n1);
- printf("Second Number: ");
- scanf("%d", &n2);
- if (n1 > n2)
- printf("%d is bigger than %d. /n", n1, n2);
- else if (n1 == n2)
- printf("They are equal. /n");
- else
- printf("%d is less than %d. /n", n1, n2);
- return 0;
- }
/** (Quiz) 1.
* Expression:' Scanner input = new Scanner(System.in); '
* means what? Is it correct if I understand them this way: Create a 'new' 'Scanner' INSTANCE from 'Scanner' class
* and using 'System.in' METHOD as standard system input?
*/
/** (Quiz) 2.
* Expression: 'n1 = input.NextInt();'
* What is this means? I think it is: 'input' (a INSTANCE of Scanner CLASS) using NextInt() METHOD to aquire a value
* and pass it to n1?? What is the NextInt(), FUNCTION, METHOD, or INTERFACE??
*/
/** Any comments is welcomed.*/