Objective of this Program: To write your first Java program. To get familiar with some of the compiler errors generated in Java. To see how one generates output from a program.
This assignment is inspired by the first programming assignment for Chapter 2 on page 106 of the text. You should develop the project in a subdirectory on the C:drive and all relevant files should ALL be in this directory.
This project consists of three parts:
public class Test { public static void main(String[] args) { System.out.println("An Emergency Broadcast"); } }For help on doing this, see the How to create a Project using Bluej, which gives a step-by-step process (with images) on how to do it.
(a) Change Emergency to emergency. (b) Remove the first quotation mark in the string literal. (c) Remove the last quotation mark in the string literal. (d) Change println to bogus. (e) Change Broadcast to Brxoadxcaxst. (f) Remove the semicolon at the end of the println statement. (g) remove the last brace in the program. (h) Remove the 'static' from the program.
public static void oneLine()
The three different ways are:
(a) on one line: Knowledge is Power (b) centered on three lines: Knowledge is power (c) inside a box made up of the characters '=' and '|' ==================== | | | Knowledge is Power | | | ====================The class which drives it should look like:
/** * Write a description of class UseKnowledge here. * * This is a driver to call three methods to write "Knowledge is Power" * three different ways. * @author PUT YOUR NAME HERE * @version PUT THE DATE HERE */ public class UseKnowledge { public static void main(String[] args) { oneLine(); centered(); boxed(); centered(); } private static void oneLine() { // write your code here to output part (a) } private static void centered() { // write your code here to output part (b) } private static void boxed() { // write your code here to output part (c) } }//end of class UseKnowledgeNote: The second use of centered is not by mistake. It is put there to show you that you can call any method as often as you want.
The prototype above of UseKnowledge.java can be downloaded.
Note:There is discussion of using System.out.print on pages 66-71 of the text.
You should post your project as a 'zip' file on the COL website. Also indicate how many hours you worked on the program in the Readme.txt file.
(1) A text file describing the what happened for each of the 7 changes
done in Part II. For those which give errors, state the error message; for
those which did not give errors, explain why and tell what output was generated
for the change. This should be done in the Readme.txt file indicated
above.
(2) The project for Part III.
(Note that no 'Word' files should be sent, only text files. If you type the answers in a Word file, then save it as a text (txt) file before attaching it.
If a 'Word" file is sent to me, I will
resend it back without opening it. Only text files will be accepted.
Homepage of CTI School
back to 211 homepage