BLUEJ编辑JAVA程序的一个小白问题

来源:百度知道 编辑:UC知道 时间:2024/05/26 16:58:55
我以前从来碰过编程,现在老师要求用BLUEJ编个简单的程序,题目如下:
Write one application that prints "Knowledge is Power" in three different ways. Each way should be done as a separate method in your class UseKnowledge. Each method should be declared as a static method, as for example,
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 |
| |
====================

然后老师也给出了程序的基版:
/**
* 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 HER

public class UseKnowledge
{

public static void main(String[] args)
{
oneLine();
centered();
boxed();

}

public static void oneLine()
{
// write your code here to output part (a)
System.out.println("Knowledge is Power");

}

public static void centered()
{
// write your code here to output part (b)
System.out.println("Knowledge");
System.out.println("is");
System.out.println("power");

}

public static void boxed()
{
// write your code here to output part (c)

System.out.println("==================== ");
System.out.println("| | ");
System.out.println("| Knowledge is Power | ");
System.out.println("| | ");
System.out.println("==================== ");

}

}//end of class UseKnowledge