HW2.6

import java.util.Scanner;
public class Solution
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.print("Enter a number between 0 and 1000: ");
int number = input.nextInt();
int sum = 0;
if(number > 0 && number < 1000)
{
if(number >= 100)
sum += number / 100 + number % 10 + (number / 10) % 10;
else if(number >= 10)
sum += number / 10 + number % 10;
else
sum += number % 10;
}
System.out.println("The sum of the digits is " + sum);
input.close();
}
}
HW2.6的更多相关文章
- JAVA HW2
MODEL //yuec2 Yue Cheng package hw2; import java.io.File; import java.io.FileNotFoundException; impo ...
- Software Testing hw2
Fault的定义:可能导致系统或功能失效的异常条件(Abnormal condition that can cause an element or an item tofail.),可译为“故障”. ...
- HW2.25
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW2.24
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW2.23
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW2.22
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW2.21
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW2.20
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW2.19
public class Solution { public static void main(String[] args) { char outcome; long randomNumber; wh ...
- HW2.18
public class Solution { public static void main(String[] args) { System.out.println("a" + ...
随机推荐
- Binding的源和路径
书上写着:Binding的源也就是数据的源头.Binding对于源的要求很简单-只要他是一个对象!并且通过属性(Property)公开自己的数据,它就可以作为Binding的源了.就像上一篇我写的那个 ...
- java创建多线程(转载)
转载自:Java创建线程的两个方法 Java提供了线程类Thread来创建多线程的程序.其实,创建线程与创建普通的类的对象的操作是一样的,而线程就是Thread类或其子类的实例对象.每个Thread对 ...
- JSP中pageEncoding和charset区别,中文乱码解决方案(转载)
转载自:JSP中pageEncoding和charset区别,中文乱码解决方案 JSP指令标签中<%@ page contentType="text/html;charset=GB23 ...
- [JavaScript] 初中级Javascript程序员必修学习目录
很多人总感觉javascript无法入门,笔者在这里写一下自己的学习过程,以及个人认 为的最佳看书过程,只要各位能按照本人所说步骤走下去,不用很长时间,坚持 个3个月,你的js层级会提高一个档次,无他 ...
- android ListView内数据的动态添加与删除
main.xml 文件: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns ...
- 解决Ubuntu14.04下Clementine音乐播放器不能播放wma文件的问题
参考:Ubuntu 14.04 安装深度音乐的方法 问题描述:播放wma文件时提示"GStreamer插件未安装". 解决方法:安装gstreamer-ffmpeg插件即可解决问题 ...
- 类型<T> where T:class的用法
public void Delete<T>(List<T> EntityList) where T : class, new() 就是说T必须是一个类(class)类型,不能是 ...
- Altium Designer 特定网络取消 remove loops
在使用Altium Designer时,在PCB Editor 里面可以设定是否需要Automatically remove Loops,但是这个设置是全局的,在设计时难免会遇到对大部分网络是需要删除 ...
- Python解决codeforces ---- 1
第一题 1A A. Theatre Square time limit per test 2 seconds memory limit per test 64 megabytes input stan ...
- 添加service到SystemService硬件服务
添加service到SystemService: 添加硬件服务. 创建时间:2015年3月9日(星期一) 晚上11:07 | 分类:硬件驱动Android | 天气: 修改时间:2015年3月10日( ...