📄 cw1d.java
字号:
/**
* Author: Jing Han
* Date; 29/10/03
*Module: G6DICp
* Title: ICP Coursework 1
* SCSiT Username: jxh23m
*/
class cw1d
{
public static void main(String arg[])
{
// print out the title banner
System.out.print("|"+"");
// for loop for print out "-"
for(int line=0;line<=56;line++)
{
System.out.print("-");
}
System.out.println();
//print out sencond line and third line
System.out.println("|"+" "+"G6DICP Coursework 1 - FizBuz Simulator"+" ");
System.out.println("|");
System.out.println("|"+" "+"by"+" "+"Jing Han");
System.out.println("|");
System.out.print("|");
// for loop for print out"_" again
for(int line=0;line<=56;line++)
{
System.out.print("-");
}
System.out.println();
// start to print out numbers
//outer loop for control 10 rows
int number=0;
//inner loop for print out 10 number per line and raise the number
for(int row=1;row<=10;row++)
{
for(int col=1;col<=10;col++)
{
number++;
if(number<=10)
{
if(number%5==0)
{
System.out.print("Fiz"+" ");
}
else if(number%7==0)
{
System.out.print("Buz"+" ");
}
else
{
System.out.print(number+" ");
}
}
else
{
if(number%50==7||number%70==5)
{
System.out.print("FizBuz"+" ");
}//end of if contain 5 and 7
else if(number%5==0||TButils.number2str(number/10,0).equals("5"))
{
System.out.print("Fiz"+" ");
} // end of if divisible by 5 and contain 5
else if(number%7==0||TButils.number2str(number/10,0).equals("7"))
{
System.out.print("Buz"+" ");
} // end of if divisible by 7 and contain 7
else
{
System.out.print(number+" ");
} // end of else
} // end of if
} // end of inner for
System.out.println();
} // end of outter for
} // end of main method
} // end of class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -