我叫王超然,是一名电脑爱好者,现在在新加坡留学上高一.我立志成为一名电脑人才,愿意在这里与大家一同分享我玩转电脑的心得.O-level华文考了A-One哈哈!
天气: 晴朗
心情: 高兴
/*
* Wang Chaoran
* Description:10 (Finding numbers divisible by 5 and 6)
Write a program that displays all the numbers from 100 to 1000,
ten per line, that are divisible by 5 and 6.
*/
public class P3Q10
{
public static void main(String[]args)
{
String output="";
//calculate the numbers divisivle by 5 and 6
for(int i=100;i<1001;i++)
{ //output the answer ten per line
if(i%300==120)
{
output=output+"\n";
}
if (i%5==0L&&i%6==0)
{
output=output+i+" ";
}
}
//output the answer
System.out.println("Numbers divisible by 5 and 6(from 100 to 1000): "+output);
}
}
导入论坛查看(33)回复(0)引用(0)好评(0) 差评(0)
加入收藏
编辑
审核
TAG:
computing