Page 14 of 30 FirstFirst ... 4121314151624 ... LastLast
Results 131 to 140 of 297

Thread: "Hello Ubuntu" in every programming language

  1. #131
    Join Date
    Mar 2006
    Location
    Philadelphia, PA
    Beans
    470

    Re: "Hello Ubuntu" in every programming language

    PHP-GTK
    Code:
    #!/usr/bin/php
    
    <?php
    if (!class_exists("Gtk"))
    {
        echo "Error: PHP-GTK libraries are not installed.";
        exit(1);
    }
    
    function on_okay_clicked($label, $entry)
    {
        $label->set_text("Hello, ".ucfirst($entry->get_text())."! Welcome to Ubuntu!");
    }
    
    $window = new GtkWindow(Gtk::WINDOW_TOPLEVEL);
    $window->set_title("Hello Ubuntu");
    
    $vbox = new GtkVBox(true, 0);
    $label = new GtkLabel("Hi, Whats your name?");
    $entry = new GtkEntry(null, 20);
    $button = GtkButton::new_from_stock(Gtk::STOCK_OK);
    
    $window->connect_simple("destroy", array("Gtk", "main_quit"));
    $button->connect_simple("clicked", "on_okay_clicked", $label, $entry);
    
    $vbox->pack_start($label, true, true, 0);
    $vbox->pack_start($entry, true, true, 0);
    $vbox->pack_start($button, true, true, 0);
    
    $window->add($vbox);
    $window->show_all();
    Gtk::main();
    ?>
    Get PHP-GTK from: http://gtk.php.net/
    Ubuntu User #: 0x2695 | Banshee 1.8/2.0 Pidgin Plugin

    Intel Q6600 @3.21, 4GB, GTX260, ArchLinux
    Lenovo IdeaPad S10, 1.6GHz Intel Atom, ArchLinux

  2. #132
    Join Date
    Sep 2007
    Beans
    8

    Re: "Hello Ubuntu" in every programming language

    PLUA
    Code:
    ptitle("Yo")
    pmoveto(120,120)
    name = ""
    field1 = pfield
    button1 = pbutton(130,110)
    while 1 do
    i = pevent(button1, click)
    if i
    do
    gettext(field1, name)
    pmoveto(130,90)
    print("Hello,"+name+" , welcome to UBUNTU! (From the palm pilots!)")
    endif
    fi
    pevent
    V
    (Made up by Dr. Voodoo of http://www.cpplc.net/forum (I made up teh name))
    Code:
    {
         print "Hello, welcome to Ubuntu!\n"
    }
    It's a hodge-podge pascal/basic/curly bracket language!
    Last edited by Seismosaur; October 5th, 2007 at 01:26 AM.

  3. #133
    Join Date
    Nov 2006
    Beans
    1,134

    Re: "Hello Ubuntu" in every programming language

    LSL
    Code:
    default
    {
        touch_start(integer num)
        {
            integer i;
            for (i = 0; i < num; i++)
            {
                llSay(PUBLIC_CHANNEL, "Hello, " + llDetectedName(i) + "! Welcome to Ubuntu!");
            }
        }
    }

  4. #134
    Join Date
    Mar 2006
    Location
    Canada
    Beans
    1,313
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: "Hello Ubuntu" in every programming language

    Quote Originally Posted by Seismosaur View Post
    PLUA
    Code:
    ptitle("Yo")
    pmoveto(120,120)
    print("Hello, ubuntu (From teh palm pliots!!!!!)")
    V
    (Made up by Dr. Voodoo of http://www.cpplc.net/forum (I made up teh name))
    Code:
    {
         print "Hello, welcome to Ubuntu!\n"
    }
    It's a hodge-podge pascal/basic/curly bracket language!
    Neither of those ask for the user's input, so I don't think they're valid.

  5. #135
    Join Date
    Sep 2007
    Beans
    8

    Re: "Hello Ubuntu" in every programming language

    Quote Originally Posted by altonbr View Post
    Neither of those ask for the user's input, so I don't think they're valid.
    Oops @ Plua, but V doesan't support input (yet) :-\.

  6. #136
    Join Date
    Oct 2007
    Beans
    13

    Re: "Hello Ubuntu" in every programming language

    Quote Originally Posted by Pazin~ View Post
    Improvements are welcome
    I'm a beginner java programmer.

    JAVA


    Code:
    import java.io.*;
    
    public class HelloUbuntu {
    	
    	public static void main(String[] args){
    		
    		System.out.println("Hi! What's your name? \n");
    
    		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    
    		String userName = null;
    
    		try{
    			userName = reader.readLine();
    		}
    		catch( IOException e ){
    			System.out.println("Ops! A problem!");
    		}
    
    		System.out.println("Hello, "+userName+" ! Welcome to Ubuntu!");
    
    	}
    }
    Lol learn to ident. You don't need to use println if you're going to use the new line character. println will print, then take a new line. You could also use Scanner to read System.in for this small application, as Scanner is quite okay for small apps, otherwise, it's good to use BufferedReader on larger apps.

    Also, why are you taking new lines for every single line? It's not nice to read, pure ugly, all it does is make the class file bigger, and confuse you. You have imported the IO class with a *. This is not quite following Java conventions if you only need 1 class. It is good practise to only import what you need.

    Code:
    import java.io.BufferedReader;
    
    public class HelloUbuntu {
    	
    	public static void main(String[] args) {		
    		System.out.println("Hi! What's your name?");
    		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    		try {
    			String userName = reader.readLine();
    		} catch(IOException e) {
    			System.out.println("Ops! A problem!");
    		}
    		System.out.println("Hello, "+userName+"! Welcome to Ubuntu!");
    
    	}
    }
    is much better in my opinion.

  7. #137
    Join Date
    Aug 2006
    Location
    Canada
    Beans
    154
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: "Hello Ubuntu" in every programming language

    Fixed C++
    Code:
    #include <iostream>
    #include <string>
    
    using namespace std;
    
    int main()
    {
        cout << "What's your name? ";
        
        string name;
        getline(cin, name);
        
        cout << "Hello, " << name << "! Welcome to Ubuntu!" << endl;
        
        return 0;
    }
    Removed unneeded headers, unnecessary entry point prototype, global variable and allowed application to accept spaces in the name.

  8. #138
    Join Date
    Aug 2006
    Beans
    66

    Re: "Hello Ubuntu" in every programming language

    SQL (using MySQL)

    Setup:

    create database ubuntu;
    use ubuntu;
    create table users ( id int primary key, name varchar(255) );
    create view hello as select concat( "Hello, ", ( select name from ubuntu.users limit 1 ), "! Welcome to Ubuntu!" ) as message;

    User input:

    insert into users ( name ) values ( 'YOUR NAME' );

    Output:

    select * from hello;

  9. #139
    Join Date
    Jun 2007
    Location
    Planet Earth, Milky Way
    Beans
    177
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: "Hello Ubuntu" in every programming language

    Java
    Code:
    import javax.swing.JOptionPane;
    public class HelloUbuntu {
    
        public static void main(String[] args) {
            
    String username;
    
    username = JOptionPane.showInputDialog("Hi, what's your name?");
    
    JOptionPane.showMessageDialog(null, "Hi, " + username +" welcome to Ubuntu!","Welcome", JOptionPane.PLAIN_MESSAGE);
    System.exit(0);
        }
    
    }
    Last edited by jose158; November 6th, 2007 at 02:41 AM.

  10. #140
    Join Date
    Sep 2006
    Location
    New York, NY
    Beans
    129
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Re: "Hello Ubuntu" in every programming language

    TI-BASIC
    Code:
    Input "WHAT'S YOUR     NAME? ",Str1
    Disp Str1
    can't be run on a computer, but I felt it was a glaring omission.
    (btw: tons of spaces so 'name?' doesn't get cut across lines )

Page 14 of 30 FirstFirst ... 4121314151624 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •