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/
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! :D
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!");
}
}
}
Re: "Hello Ubuntu" in every programming language
Quote:
Originally Posted by
Seismosaur
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! :D
Neither of those ask for the user's input, so I don't think they're valid.
Re: "Hello Ubuntu" in every programming language
Quote:
Originally Posted by
altonbr
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) :-\.
Re: "Hello Ubuntu" in every programming language
Quote:
Originally Posted by
Pazin~
Improvements are welcome :D
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.
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.
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;
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);
}
}
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 ;))