Now to create a program. There are various editors you can use.
On the lower left of your screen is a "K" in front of the screen; it's
gives you a menu of available programs. Under "editors" you'll see "advanced
editor", "kate", and "emacs", among others. Select Kate. (
You could use another
but Kate's nice.) You'll get a window
with parts, the one on the right being an editor window.
Even though you haven't entered any text, save the file in your
labs directory with the name lab1.java. Now enter the following program
and save it when you're finished. Type it in as is with the exception of filling in the
comment section at the top with appropriate values
(your name, login ID, etc.) This source code does contain
a couple of intended syntax errors, but leave them in for now.
You might accidentally create another
syntax error if you make a typing mistake (which is easy to do, of course),
but try not to.
/******************************************************************
*
* lab1.java: My first Java Program
*
* Name: <your name>
* Login: <your login id>
* Course: CSci 101
* Section: <your section>
* Date: <todays date>
*
* Description:
* This program reads in a length in feet from the keyboard
* and converts the length to a number of inches, which is
* output to the console screen. It is assumed that the
* input length is a positive integer.
*
*******************************************************************/
public class lab1 {
public static void main(String args[])
{
int foot;
int inches;
System.out.print("\n Enter length in feet: ");
foot = SavitchIn.readLineInt();
/* this is the conversion
inches = 12 / foot
System.out.print(" " + foot + " feet is equal to ");
System.out.println(inches + " inches.");
}
}