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. HIVE中内连接和左半连接不一致问题

    一.理论 HIVE中都是按等值连接来统计的,理论上两种写法统计结果应该是一致的: 二.实际情况 但实际使用中发现两种写法会返回的结果,总会有一些差距虽然差别不大,但让人很是困惑. 三.原因 当使用jo ...

  2. repo manifest xml 文件修改后提交命令

    git push origin dev(本地分支):refs/for/tv/Internal_Jb910_develop_t

  3. C# zip/unzip with DotNet framework 4.5

    add reference System.IO.Compression.FileSystem public class ZipHelper { public static string UnZip(s ...

  4. Spring MVC 注解和XML的区别

      注解与XML配置的区别 注解:是一种分散式的元数据,与源代码紧绑定. xml:是一种集中式的元数据,与源代码无绑定. 因此注解和XML的选择上可以从两个角度来看:分散还是集中,源代码绑定/无绑定. ...

  5. 微软Hololens学院教程- Holograms 101: Introduction with Device【微软教程已经更新,本文是老版本】

    这是老版本的教程,为了不耽误大家的时间,请直接看原文,本文仅供参考哦!原文链接:https://developer.microsoft.com/EN-US/WINDOWS/HOLOGRAPHIC/ho ...

  6. axure rp pro 6.5

    现在地址:http://www.xdowns.com/soft/1/95/2012/Soft_94434.html Axure6.5正式版推出了,大大改善了用户体验以及修复了很多6.0上的bug. 而 ...

  7. Portal相关技术及架构

    Portal以用户为中心,提供统一的用户登录,实现信息的集中访问,集成了办公商务一体的工作流环境.利用Portal技术,可以方便地将员工所需要的,来源于各种渠道的信息资料集成在一个统一的桌面视窗之内. ...

  8. xxx couldn't be loaded because it has not been added to the build settings.

    这个由于没有将进入场景放入Build Settings里面造成的.

  9. MemoryStream类

    转自:http://www.cnblogs.com/kissdodog/archive/2013/01/20/2868864.html MemoryStream 是一个特例,MemoryStream中 ...

  10. Linux中断处理流程

    http://blog.csdn.net/dianhuiren/article/details/7468956