Current Status

Book

Program Phases, A Programming Language and API Translator allows programmers to learn new programming languages by providing simple indexed example programs. Each program illustrates useful, common, and well defined functionality.

Coda-Slider 1.1.1

Program Phase Task 1 Hello World! with Strings

Source Code

Program Phase 1-1 Java



//***********************************************************************************
// Program Phase 1-1 Java Hello World! with Strings
// Programming Tasks Illustrated: Console Application
//                                Integer and String Variable Declarations
//                                Application Command Line Parameters
//                                Case/Switch Statement
//                                String Literal Assignment and Concatenation
//                                Console Application Standard Output
//***********************************************************************************


//***********************************************************************************
// File: pp1_1.java
// Reserved
//***********************************************************************************

package programphases.programphase1_1;

public class pp1_1
{ 


//***********************************************************************************
// Program Phase 1-1 Main
// Define the Entry Point of Execution (EPE) for Program Phase 1-1
// CBI:  1-1.1.1.1
//***********************************************************************************

public static void main(final String argv[])
{


//***********************************************************************************
// Program Phase 1-1 Main
// Declare the local variables for the "main" program
// CBI:  1-1.1.1.2
//***********************************************************************************
 
   int lnCmdLineParamCount; 
   String lcString1;
   String lcString2;
   String lcStringOutput1;
   String lcStringOutput2;


//***********************************************************************************
// Program Phase 1-1 Main
// Store the command line parameters
// CBI:  1-1.1.1.3
//***********************************************************************************

   // The local argv array stores the command line parameters.
   lnCmdLineParamCount = argv.length; 


//***********************************************************************************
// Program Phase 1-1 Main
// Parse the command line parameters using a Case/Switch statement
// CBI:  1-1.1.1.4
//***********************************************************************************

   switch (lnCmdLineParamCount)
   {
      case 0:
         lcStringOutput1 = "You entered no command line parameters.";
         break; 

          
      case 1:
         lcStringOutput1 = "Command line parameter entered: " + argv[0];
         break;
       
      default:
         lcStringOutput1 = "The command line is limited to 1 parameter.";
   }


//***********************************************************************************
// Program Phase 1-1 Main
// Concatenate two string variables
// CBI:  1-1.1.1.5
//***********************************************************************************

   lcString1 = "Hello";
   lcString2 = "World!";
   lcStringOutput2 = lcString1 + " " + lcString2; 


//***********************************************************************************
// Program Phase 1-1 Main
// Output to standard output
// CBI:  1-1.1.1.6
//***********************************************************************************

   System.out.println(lcStringOutput1);
   System.out.println(lcStringOutput2); 
}} 


« Previous | Next »

Code Setup and Compilation

Program Phase 1-1 Java
  1. Start the Netbeans IDE program.

  2. Netbeans -> Activate Menu Item: File -> New Project
    Select the "Java" category and then select "Java Application" as the project type. Activate the "Next" button.

  3. Enter pp1_1 as the "Project Name".
    Enter the appropriate folder name for the "Project Location". Check the "Set as Main Project" check box. Uncheck the "Create Main Class" check box. Activate the "Finish" button.

  4. Create a folder called programphases\programphase1_1 inside the src folder of the pp1_1 folder. Example: pp1_1\src\programphases\programphase1_1

  5. Netbeans - Activate Menu Item: File -> New File
    In the "New File" dialog window, select the "Other" category and then select "Empty File" as the file type. Activate the "Next" button. Enter the "File Name" as pp1_1.java and select the src\programphases\programphase1_1 folder as the destination "Folder". Activate the "Finish" button to create the pp1_1.java file.

  6. Open the pp1_1.java file in the Netbeans IDE and then enter the source code for Program Phase 1-1.

« Previous | Next »

Program Execution

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus porta tortor sed metus. Nam pretium. Sed tempor. Integer ullamcorper, odio quis porttitor sagittis, nisl erat tincidunt massa, eu eleifend eros nibh sollicitudin est. Nulla dignissim. Mauris sollicitudin, arcu id sagittis placerat, tellus mauris egestas felis, eget interdum mi nibh vel lorem. Aliquam egestas hendrerit massa. Suspendisse sed nunc et lacus feugiat hendrerit. Nam cursus euismod augue. Aenean vehicula nisl eu quam luctus adipiscing. Nunc consequat justo pretium orci. Mauris hendrerit fermentum massa. Aenean consectetuer est ut arcu. Aliquam nisl massa, blandit at, accumsan sed, porta vel, metus. Duis fringilla quam ut eros.

Sed eu ligula eget eros vulputate tincidunt. Etiam sapien urna, auctor a, viverra sit amet, convallis a, enim. Nullam ut nulla. Nam laoreet massa aliquet tortor. Mauris in quam ut dui bibendum malesuada. Nulla vel erat. Pellentesque metus risus, aliquet eget, eleifend in, ultrices vitae, nisi. Vivamus non nulla. Praesent ac lacus. Donec augue turpis, convallis sed, lacinia et, vestibulum nec, lacus. Suspendisse feugiat semper nunc. Donec nisl elit, varius sed, sodales volutpat, commodo in, elit. Proin ornare hendrerit lectus. Sed non dolor. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Duis suscipit. Mauris egestas tincidunt lectus. Phasellus sed quam et velit laoreet pretium. Nunc metus.

« Previous | Next »