永发信息网

用JAVA语言编写程序

答案:3  悬赏:40  手机版
解决时间 2021-03-15 22:41
用JAVA语言编写程序
最佳答案
public class Test {
public static void main(String args[])

{
int n=100,m=200;
int sum=0,tem=0;
System.out.println("100到200之间所以3的倍数为:");
for(int i=n;i<=m;i++)
{
if(i%3==0)
{
System.out.print(i+" ");
sum+=i;
tem++;
}
if(tem%10==0)
System.out.println();

}
System.out.println();
System.out.print("所有3的倍数之和为:"+sum);
}
}
全部回答
import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;public class SaleTickets { private static int getChoice() {BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));int result;try {result = Integer.parseInt(reader.readLine());}catch(NumberFormatException e) {result = -1;}catch(IOException ioe) {return -1;}return result; }public static void main(String[] args) {int noSmoking = 5; //指示当前应该分配的无烟区int somking = 0;//指示当前应该分配的吸烟区int choice;System.out.println("1 Please type 1 for \"smoking\":\n" +"2 Please type 2 for \"no somking\":\n" +"0 Exit the system");choice = getChoice();while(choice != 0) { //分配座位 switch(choice) {case 1: //吸烟区if(somking < 5) {System.out.println("Congratulations, yout got a seat in somking area " + "your seatNo is " + (somking++ + 1));}//吸烟区已经没有座位了else {System.out.println("There is no seat is smoking area, " + "would you like a seat in no smoking area? type 1 for yes and 0 for no: "); switch(getChoice()) {case 1:if(noSmoking < 10) {System.out.println("Congratulations, you got a seat in no smoking area" + " your seatNo is " + (noSmoking++ + 1));}else {System.out.println("wait for next flight!");}break; case '0':default: break; }}break; case 2://无烟区if(noSmoking < 10) {System.out.println("Congratulations, you got a seat in no smoking area" + " your seatNo is " + (noSmoking++ +1));}else {System.out.println("wait for next flight!");}break;default: System.out.println("Invalid choice!"); }System.out.println("1 Please type 1 for \"smoking\":\n" + "2 Please type 2 for \"no somking\":\n" + "0 Exit the system"); choice = getChoice();}System.out.println("Good bye!"); }}没有按你的提示来实现。
import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;public class SaleTickets { private static int getChoice() {BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));int result;try {result = Integer.parseInt(reader.readLine());}catch(NumberFormatException e) {result = -1;}catch(IOException ioe) {return -1;}return result; }public static void main(String[] args) {int noSmoking = 5; //指示当前应该分配的无烟区int somking = 0;//指示当前应该分配的吸烟区int choice;System.out.println("1 Please type 1 for \"smoking\":\n" +"2 Please type 2 for \"no somking\":\n" +"0 Exit the system");choice = getChoice();while(choice != 0) { //分配座位 switch(choice) {case 1: //吸烟区if(somking < 5) {System.out.println("Congratulations, yout got a seat in somking area " + "your seatNo is " + (somking++ + 1));}//吸烟区已经没有座位了else {System.out.println("There is no seat is smoking area, " + "would you like a seat in no smoking area? type 1 for yes and 0 for no: "); switch(getChoice()) {case 1:if(noSmoking < 10) {System.out.println("Congratulations, you got a seat in no smoking area" + " your seatNo is " + (noSmoking++ + 1));}else {System.out.println("wait for next flight!");}break; case '0':default: break; }}break; case 2://无烟区if(noSmoking < 10) {System.out.println("Congratulations, you got a seat in no smoking area" + " your seatNo is " + (noSmoking++ +1));}else {System.out.println("wait for next flight!");}break;default: System.out.println("Invalid choice!"); }System.out.println("1 Please type 1 for \"smoking\":\n" + "2 Please type 2 for \"no somking\":\n" + "0 Exit the system"); choice = getChoice();}System.out.println("Good bye!"); }}没有按你的提示来实现。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
成都大学四川抗菌素工业研究所在哪里啊,我有
半挂车高低档怎么用
怎样设置能让监控实现云存储
华为手机保密柜可以在其他手机登吗
励志美文300字
我想问下生过小孩没结婚拿证了没拜天地算结婚
通记商店(先锋西路)地址在哪,我要去那里办事
作文零钱的研究报告表300字
关于sure的短语
在帮友贷借款,会不会给家里人打电话?还给单
由于一些原因,我把小猫养在一个比较大得纸盒
北方汽车装具这个地址在什么地方,我要处理点
美国加州牛肉面我想知道这个在什么地方
徐州哪里有卖喜德盛锂电池电动车?
中国有哪四大湖泊区
推荐资讯
怎么样才算男女朋友关系?
请问,北京市丰台区的车船使用税在哪交,我所
东福米业有限公司地址有知道的么?有点事想过
一个人有虚有实是什么成语
河南移动领导班子成员
蓬莱烈士陵园观后感
微信图片都开裂了!还可以修复吗?
白子画还是挺关心花千骨的 为什么表面上不跟
谁能把佛皇变成这样子
什么数除以32等于19余多少余数最大是多少
一滴水在理论上能浮起一艘船吗
为什么我申请的信用卡和同事一起申请的,我同
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?