中国大学MOOC-零基础学Java 编程题-第二周

1

时间换算(5分)

题目内容:

UTC是世界协调时,BJT是北京时间,UTC时间相当于BJT减去8。现在,你的程序要读入一个整数,表示BJT的时和分。整数的个位和十位表示分,百位和千位表示小时。如果小时小于10,则没有千位部分;如果小时是0,则没有百位部分;如果分小于10分,需要保留十位上的0。如1124表示11点24分,而905表示9点5分,36表示0点36分,7表示0点7分。

有效的输入范围是0到2359,即你的程序不可能从测试服务器读到0到2359以外的输入数据。

你的程序要输出这个时间对应的UTC时间,输出的格式和输入的相同,即输出一个整数,表示UTC的时和分。整数的个位和十位表示分,百位和千位表示小时。如果小时小于10,则没有千位部分;如果小时是0,则没有百位部分;如果分小于10分,需要保留十位上的0。

提醒:要小心跨日的换算。

输入格式:

一个整数,表示BJT的时和分。整数的个位和十位表示分,百位和千位表示小时。如果小时小于10,则没有千位部分;如果小时是0,则没有百位部分;如果小时不是0而且分小于10分,需要保留十位上的0。

输出格式:

一个整数,表示UTC的时和分。整数的个位和十位表示分,百位和千位表示小时。如果小时小于10,则没有千位部分;如果小时是0,则没有百位部分;如果小时不是0而且分小于10分,需要保留十位上的0。

输入样例:

933

输出样例:

133

时间限制:500ms内存限制:32000kb

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int BJT;
		int UTC;
	    Scanner in = new Scanner(System.in);
	    BJT = in.nextInt();
	    if(BJT<800)
	       {
	        UTC=(BJT+1600);
	       }
	       else
	       {
	        UTC=(BJT-800);
	       }
	       System.out.println(UTC);  
	 }
}

2

信号报告(5分)

题目内容:

无线电台的RS制信号报告是由三两个部分组成的:

R(Readability) 信号可辨度即清晰度.

S(Strength)    信号强度即大小.

其中R位于报告第一位,共分5级,用1—5数字表示.

1---Unreadable

2---Barely readable, occasional words distinguishable

3---Readable with considerable difficulty

4---Readable with practically no difficulty

5---Perfectly readable

报告第二位是S,共分九个级别,用1—9中的一位数字表示

1---Faint signals, barely perceptible

2---Very weak signals

3---Weak signals

4---Fair signals

5---Fairly good signals

6---Good signals

7---Moderately strong signals

8---Strong signals

9---Extremely strong signals

现在,你的程序要读入一个信号报告的数字,然后输出对应的含义。如读到59,则输出:

Extremely strong signals, perfectly readable.

输入格式:

一个整数,信号报告。整数的十位部分表示可辨度,个位部分表示强度。输入的整数范围是[11,59]内有效的数字,这个范围外的数字不可能出现在测试数据中。

输出格式:

一句话,表示这个信号报告的意义。按照题目中的文字,先输出表示强度的文字,跟上逗号和空格,然后是表示可辨度的文字,跟上句号。注意可辨度的句子的第一个字母是小写的。注意这里的标点符号都是英文的。

输入样例:

33

输出样例:

Weak signals, readable with considerable difficulty.

时间限制:500ms内存限制:32000kb

import java.util.Scanner;
public class Main { 	
	public static void main(String[] args) {		
		Scanner in = new Scanner(System.in);		
		int RS = in.nextInt();		
		int S = RS % 10;		
		int R = (RS - S)/10;		
		String r,s;		
		if (S == 1) 
		{			
			s = "Faint signals, barely perceptible";
			System.out.print(s+",");
			}else if(S == 2)
				{			
					s = "Very weak signals";
					System.out.print(s+",");
			}else if(S == 3)
				{			
					s = "Weak signals";
					System.out.print(s+",");
			}else if(S == 4)
				{			
					s = "Fair signals";
					System.out.print(s+",");
			}else if(S == 5)
				{			
					s = "Fairly good signals";
					System.out.print(s+",");
			}else if(S == 6)
				{			
					s = "Good signals";
					System.out.print(s+",");
			}else if(S == 7)
			  	{			
					s = "Moderately strong signals";
					System.out.print(s+",");
			}else if(S == 8)
				{
					s = "Strong signals";
					System.out.print(s+",");
			}else if(S == 9)
				{			
					s = "Extremely strong signals";
					System.out.print(s+",");
			}if(R == 1)
				{			
					r = " unreadable";
					System.out.println(r + ".");
			}else if(R == 2)
				{			
					r = " barely readable, occasional words distinguishable";
					System.out.println(r + ".");
			}else if(R == 3)
				{			
					r = " readable with considerable difficulty";
					System.out.println(r + ".");
			}else if(R == 4)
				{			
					r = " readable with practically no difficulty";
					System.out.println(r + ".");
			}else if(R == 5)
				{			
					r = " perfectly readable";
					System.out.println(r + ".");
																
				}			
	} 
}

猜你喜欢

转载自blog.csdn.net/weixin_44977914/article/details/90040408
今日推荐