0. Hello, World

Submit to TigerFile

The purpose of this assignment is to introduce you to programming in Java and familiarize you with the mechanics of preparing and submitting assignment solutions. You will learn to use IntelliJ editor for writing, compiling, and executing Java programs, and TigerFile for submitting your work electronically.

Requirements

  • Install the COS 126 Java programming environment, called IntelliJ, on your computer. Follow these step-by-step instructions carefully. If you encounter difficulties, please consult the undergraduate Lab TAs schedule and go to Lewis Library for assistance. Don’t be afraid to ask for help! Note - even if you have an existing version of IntelliJ, you should install the COS 126 version.

  • Use the project folder called hello that you downloaded after you installed IntelliJ. All assignments require that you download a project zip file and expand this this into a project folder. It’s a good idea to save this folder somewhere safe, along with all the folders you create for future assignments in the class.

  • Read both Sections 1.1 and 1.2 of the textbook. If you don’t understand something, post a question on Ed or attend office hours for assistance. Don’t be bashful about asking for help.

  • Collaboration Policy Quiz: Please read the course collaboration policy and take a short quiz on the policy (available in the Quizzes section on Canvas). You must repeat the quiz until you answer all questions correctly; otherwise, you will not receive credit for any programming assignment.

  • Entry Survey: Complete the following brief survey.

  • Implement these programs:

    • HelloWorld.java
    • Greeting.java
    • SayHelloWorld.java
    • SumThree.java

Recall, in IntelliJ, you create a new Java class with LIFT → New Java Class.

  • Complete the readme.txt and acknowledgments.txt files.

HelloWorld

Your first programming task is to write the HelloWorld program. You have actually already completed this task: first, when when you installed IntelliJ, and then again in lecture and precept, when you discussed HelloWorld.java.

HelloWorld.java

Greeting

Write a program Greeting.java that takes a greeting and two names as command-line arguments and prints the greeting as shown below (with the names for the first greeting in the same order as the command-line arguments and the names for the second greeting in reverse order).

java Greeting Hi Sonia Samuel
Hi Sonia and Samuel.
Hi Samuel and Sonia.
java Greeting Ciao Kellia Yacoub
Ciao Kellia and Yacoub.
Ciao Yacoub and Kellia.
java Greeting γεια Alexandria Homer
γεια Alexandria and Homer.
γεια Homer and Alexandria.
java Greeting "Nǐ hǎo" Ahmed Hagop
Nǐ hǎo Ahmed and Hagop.
Nǐ hǎo Hagop and Ahmed.

For greetings in a large number of languages, see HelloWorldMultilingual.java

SayHelloWorld

Write a program SayHelloWorld.java that takes the name of a sound file (of someone speaking Hello World) and plays that sound file using StdAudio.play(). Recall, StdAudio.play() takes a string as an argument (such as "HelloWorld.wav"); treats that string as the name of a sound file; and plays that sound file to your speaker.

Please note that you will need to use javac-introcs and java-introcs commands (instead of the default javac and java commands) to compile and execute your programs. These versions provide access to our course libraries, including StdAudio, which you will use in this program. To try these commands, in IntelliJ, select LIFT > Terminal. Compile your program using the javac-introcs command and execute it using the java-introcs command:

The people, google and siri subdirectories in the project directory contains a large number of WAV files of Hello World spoken in different voices and languages, both real (from various individuals) and synthetic (from Google Translate and Apple Siri). Below are some sample executions:

javac-introcs SayHelloWorld.java
java-introcs SayHelloWorld people/KevinWayne.wav
java-introcs SayHelloWorld people/AloeBlacc.wav
java-introcs SayHelloWorld google/Spanish.wav
java-introcs SayHelloWorld siri/Kyoko.wav

Also, record yourself speaking Hello, World, convert it to a WAV file named MyHelloWorld.wav, and submit that WAV file. You may speak Hello, World in whatever language you like. Here are several ways to record and convert your audio:

  • Mac OS X: Voice Memos app → Record. Drag the recording to a folder - this will create an M4A file. Then convert the M4A file to a WAV file via Zamzar
  • Mac OS X: Quicktime app → File → New Audio Recording. After making the recording, select File → Save. Then convert the M4A file to a WAV file via Zamzar
  • Windows: Sound Recorder → Record. After making the recording, select Save As. Then convert the WMA file to a WAV file via Zamzar
  • iPhone: Voice Memo app → Record. Then, copy the recording to your laptop and convert the M4A file to a WAV file via Zamzar
  • Android: Use an app that allows you record audio. Then, copy the audio file to your laptop and convert to a WAV via Zamzar

SumThree

Write a program SumThree.java that takes three integer command-line arguments and prints the three integers and their sum in the form of an equation.

java-introcs SumThree 2 5 8
2 + 5 + 8 = 15
java-introcs SumThree -2 5 -8
-2 + 5 + -8 = -5

readme.txt

Edit the text file named readme.txt that is a narrative description of your work. Each week, we provide a readme.txt file for you to download and use as a template, answering all questions in the space provided. Submit this file with your .java files.

acknowledgments.txt

Submitting the acknowledgments.txt file indicates that you have stopped working on your assignment and your submitted work is ready to be graded. The acknowledgments.txt file contains two important sections:

  1. The names and dates of those who helped you with this assignment. When you attend office hours or lab TAs sessions, you should introduce yourself and record the person’s name. For example:

    Grace Hopper (Faculty), 9/16/22
    John von Neumann (Lab TA), 9/16/22
    
  2. The Student Acknowledgment of Original Work from Rights, Rules, Responsibilities with your digital signature - /s/ followed by your full name. For example:

    This programming assignment represents my own work in accordance with University regulations. /s/ Grace Hopper
    

Submission

Submit HelloWorld.java, Greeting.java, SayHelloWorld.java, SumThree.java, and a completed readme.txt to TigerFile Please do not include your name, netid and/or email address in your .java and readme.txt files.

Login using your OIT NetID (if necessary) and upload the specified files. Finally, click the Check Submitted Files button:

TigerFile

This will compile and execute your programs, alerting you to potential problems before we grade your work. Fix any problems and resubmit. You may submit one file at a time or several files at a time. However, you may only click the Check Submitted Files button a total of twenty (20) times.

Also, complete and submit both the Collaboration Policy Quiz on Canvas and the Entry Survey

Complete and submit the acknowledgments.txt file when you have completed the assignment.

Grading

Files Points
HelloWorld.java 8
Greeting.java 8
SayHelloWorld.java 8
SumThree.java 8
readme.txt 4
Survey 4
Total 40

You must repeat the Collaboration Policy Quiz until you answer all questions correctly; otherwise, you will not receive credit for any programming assignment.

Submissions without any comments will receive style deductions. Code that is not properly formatted will also receive style deductions. (Hint - in IntelliJ, use Code → Reformat Code.)

Enrichment

Hello World in 200 Languages. Here is Hello World in over 200 different programming languages.