45A--Codecraft III

题目

Today Vasya visited a widely known site and learned that the continuation of his favourite game Codecraft II will appear after exactly k months. He looked at the calendar and learned that at the moment is the month number s. Vasya immediately got interested in what month Codecraft III will appear. Help him understand that.

All the twelve months in Vasya’s calendar are named using their usual English names: January, February, March, April, May, June, July, August, September, October, November, December.

Input

The first input line contains the name of the current month. It is guaranteed that it is a proper English name of one of twelve months. The first letter is uppercase, the rest are lowercase. The second line contains integer k (0 ≤ k ≤ 100) — the number of months left till the appearance of Codecraft III.

Output

Print starting from an uppercase letter the name of the month in which the continuation of Codeforces II will appear. The printed name must be contained in the list January, February, March, April, May, June, July, August, September, October, November, December.

Examples
input
November
3
output
February
input
May
24
output
May
题意:给出一个月份,计算出n个月后是几月份
解题思路:定义一个月份数组,存放12个月的英文单词,找出给出月份的下表i,通过计算n=(i+n)%n的值,打印出math[n]的值。
AC–Code
import java.util.Scanner;
public class CF45A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] month = {"January", "February","March","April","May",
		"June","July","August","September","October","November","December"};
		String  ms =sc.nextLine();
		int n = sc.nextInt();
		for(int i =0;i<month.length;i++)
		{
			if(month[i].equals(ms))
			{
				n =(n+i)%12;
				System.out.println(month[n]);
				break;
			}
		}
		sc.close();
	}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值