P5712 【深基3.例4】Apples

原题链接

题目描述

八尾勇喜欢吃苹果。她今天吃掉了 x(0≤x≤100) 个苹果。英语课上学到了 apple 这个词语,想用它来造句。如果她吃了 1 个苹果,就输出 Today, I ate 1 apple.;如果她没有吃,那么就把 1 换成 0;如果她吃了不止一个苹果,别忘了 apple 这个单词后面要加上代表复数的 s。你能帮她完成这个句子吗?

输入格式

输出格式

输入样例

1

输出样例

Today, I ate 1 apple.

源码

package com;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner (System.in);
		int x=sc.nextInt();
		if(x<=1)
			System.out.println("Today, I ate "+x+" apple.");
		else
			System.out.println("Today, I ate "+x+" apples.");
}
}	

以上代码仅供参考

你可能感兴趣的:(洛谷:【入门2】分支结构,nlp,csp,ios,vba,ssl)