import java.util.Scanner;

 public class Solution
 {
     public static void main(String[] args)
     {
         Scanner input = new Scanner(System.in);

         System.out.print("Enter an int value, the program exits if the input is 0: ");
         int inputValue = input.nextInt();
         int count = 1;

         int positive = 0;
         int negative = 0;
         if(inputValue > 0)
             positive = 1;
         else if(inputValue < 0)
             negative = 1;

         int sum = inputValue;

         while(inputValue != 0)
         {
             System.out.print("Enter an int value, the program exits if the input is 0: ");
             inputValue = input.nextInt();
             count++;
             sum += inputValue;
             if(inputValue > 0)
                 positive++;
             else if(inputValue < 0)
                 negative++;
         }

         float average = (float)(sum * 1.0) / count;

         System.out.println("The number of positives is " + positive);
         System.out.println("The number of negatives is " + negative);
         System.out.println("The total is " + count);
         System.out.println("The average is " + average);
     }
 }

HW4.1的更多相关文章

  1. HW4.46

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  2. HW4.45

    public class Solution { public static void main(String[] args) { int count = 0; for(int i = 1; i < ...

  3. HW4.44

    public class Solution { public static void main(String[] args) { double randX; double randY; int hit ...

  4. HW4.43

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  5. HW4.42

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  6. HW4.41

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  7. HW4.40

    public class Solution { public static void main(String[] args) { long positiveSide = 0; long negativ ...

  8. HW4.39

    public class Solution { public static void main(String[] args) { double sum; double baseSalary = 500 ...

  9. HW4.38

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  10. HW4.37

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

随机推荐

  1. 2016032701 - ubuntu安装jdk

    参考地址:http://jingyan.baidu.com/article/d621e8da0e92052865913f32.html 1.首先需要去oracle官网去下载jdk1.8,我本人下载的是 ...

  2. Hadoop常见的45个问题解答

    (大讲台:国内首个it在线教育混合式自适应学习) 1.Hadoop集群可以运行的3个模式 单机(本地)模式 伪分布式模式 全分布式模式 2.  单机(本地)模式中的注意点? 在单机模式(standal ...

  3. HBase性能优化方法总结(转)

    本文主要是从HBase应用程序设计与开发的角度,总结几种常用的性能优化方法.有关HBase系统配置级别的优化,这里涉及的不多,这部分可以参考:淘宝Ken Wu同学的博客. 1. 表的设计 1.1 Pr ...

  4. ionic+angulajs

    基于ionic+angulajs的混合开发实现地铁APP 项目源码地址:https://github.com/zhangxy1035/SubwayMap 一.项目简介 在该项目中的地铁app是基于io ...

  5. DB天气安卓客户端测试计划

      分辨率 屏幕ppi 网络环境 操作系统 os 用户类型 地点 组合总数 其他 samsung                   htc                   小米         ...

  6. Codeforces Round #327 div2

    Problem_A(591A): 题意: 有一段长度为l的路,两个人分别在两个端点,1, l. 现在已知每个人的速度为p,q. 求第一个人(初始位置在1)在他们第二次相遇的时候的位置. 当他们相遇的时 ...

  7. LINUX Shell 下求两个文件交集和差集的办法

    http://blog.csdn.net/autofei/article/details/6579320 假设两个文件FILE1和FILE2用集合A和B表示,FILE1内容如下: a b c e d ...

  8. android ExpandableListActivity的使用

    package com.example.keKuoZhanLieBiao; import android.app.ExpandableListActivity; import android.os.B ...

  9. android 在activity中改变标题栏的标题 tabActivity的标题改变

    在activity中改变标题栏的标题是调用setTitle()方法,参数为标题名称. 而tabActivity跟Activity是一样的,因此在onCheckedChanged()方法中要动态改变标题 ...

  10. TC SRM 607 DIV2

    求拼接完成后的字符串包含的子回文串的数目,一开始还用暴力去做,想都不用想 肯定超时了. 复习了一下求最长子回文串的算法,发现可以类似解决. 给相邻字符之间添加一个'@'字符,这样所有的回文串都是奇数长 ...