首页 > 编程语言 >Java - function

Java - function

时间:2024-06-17 09:12:07浏览次数:27  
标签:function deviation Java number numbers array your mean

 

Java - Assignment 04 (100 pts)

Instructions

  • Write each exercise in its own method. Uncomment the function calls in main() to activate each

exercise. Refer to "Assignment01" if necessary.

  • For each exercise, use comments to write pseudocode with at least one additional refinement

step. Include the pseudocode at the beginning of each method.

  • Submit only one file containing all of your code. Multiple files not allowed!
  • The knowledge required for this assignment is in the textbook / slides and your notes. You are

not allowed to use any additional resources, websites, external help... Doing so will be

considered plagiarism and / or cheating! If you need help, talk to a CIS tutor or to the professor.

  • But you are allowed to assist your friends during the lab session in the presence of the professor.
  • If you are having problems unrelated to the assignment (for example, you are unable to find a

specific function in your IDE, …), you can go ahead and check it on the Internet.

  • Do not use functions/techniques that have not been covered in class yet. Doing so might be

mistaken for plagiarism and/or defeats the purpose of the exercise and will be graded 0.

  • You are required to perform at least one submission at the end of the lab session, even if it’s

incomplete. You can complete it later and resubmit it; the latest one will be graded.

  • Test all your methods at least 3 times in main() by calling them with different parameters

Exercise 01 (25 pts)

Write a method public static void distinct(int[] arrNumbers) that receives an array

of ten numbers and displays the number of distinct numbers and the distinct numbers separated by exactly

one space (i.e., if a number appears multiple times, it is displayed only once). (Hint: Read a number from

the input array and store it in a local array if it is new. If the number is already in the local array, ignore

it.) At the end, the local array will contain the distinct numbers. Here is a sample run of the program:

(assuming that the input array contains 1 2 3 2 1 6 3 4 5 2)

The number of distinct number is 6

The distinct numbers are: 1 2 3 6 4 5

Exercise 02 (30 points)

Use the following formula to compute the standard deviation of n numbers:

标签:function,deviation,Java,number,numbers,array,your,mean
From: https://www.cnblogs.com/qq99515681/p/18251698

相关文章

  • 面试官:Java中缓冲流真的性能很好吗?我看未必
    一、写在开头上一篇文章中,我们介绍了JavaIO流中的4个基类:InputStream、OutputStream、Reader、Writer,那么这一篇中,我们将以四个基类所衍生出来,应对不同场景的数据流进行学习。二、衍生数据流分类我们上面说了java.io包中有40多个类,都从InputStream、OutputStream、Reader、Wr......
  • 第二章JAVA的第一个开发程序
    1.JAVA的源文件以:.java结尾2.class:类,代码容器class类名Hello{  publicstaticvoidmain(String[]args){  System.out.println("Hello,world");  }}(1)main函数:被称为主函数,程序的入口,一个类中最多只能有一个主函数(2)System.out.println();//控制台打印出......
  • 5 个 JavaScript 自定义的实用函数
    嘿!......
  • Java高手的30k之路|面试宝典|精通Map篇
    HashMapHashMap是Java集合框架中非常重要的一部分,它是基于哈希表的数据结构。1.基于哈希表的实现HashMap基于哈希表实现。哈希表是通过将键(Key)映射到值(Value)的一种数据结构。具体来说,HashMap使用一个数组和链表(在冲突较少时)或红黑树(在冲突较多时)来存储元素。2.负......
  • 【Java基础】输入输出流(IO流)
     目录一、流的概念二、输入输出流的类层次结构图三、使用 InputStream 和 OutputStream流类四、使用Reader和Writer流类Java语言的输入输出功能必须借助于输入输出包java.io来实现,Java开发环境提供了丰富的流类,完成从基本的输人输出到文件操作。利用java.io......
  • JAVA 程序 在 cmd 窗口的运行
    1、在指定路径创建文件:eg文件名称:Hello.java;2、在文件内部输入内容:publicclassHello{publicstaticvoidmain(String[]args){System.out.println("Helloworld!");}}3、在cmd运行命令javac+文件名称Hello.java4、生成Hello.class......
  • Java基础:B树、B+树和红黑树的数据结构,三者区别
    B树(B-Tree)数据结构节点结构:每个节点包含多个键值和子节点指针。阶(Degree):B树的阶定义了每个节点的最小和最大键值数。对于阶为(m)的B树:每个节点最多有(m-1)个键值和(m)个子节点。每个节点(除了根节点)至少有(\lceilm/2\rceil-1)个键值和(\lceilm/......
  • 【JavaWeb】SpringBootWeb请求响应
    前言在上一次,我们开发了springbootweb的入门程序。基于SpringBoot的方式开发一个web应用,浏览器发起请求/hello后,给浏览器返回字符串“HelloWorld~”。其实呢,是我们在浏览器发起请求,请求了我们的后端web服务器(也就是内置的Tomcat)。而我们在开发web程序时呢,定义了一个控......
  • 自学编程Java入门基础教学
    (首先下载typora/15天免费使用)MARKDOWN标题(符号必须英文输入法)标题#(#个数分级别)空格文案二级标题三级标题文字world!(前后两个*加粗)world!(1斜体*)world!(3*斜体加粗)world!(两个~波浪号删除线)引用吗喽小帆船自学Java寻大厂offer(>空格)分割线(三个-获三个*分割线)......
  • [Java]讲解@CallerSensitive注解
    【版权声明】未经博主同意,谢绝转载!(请尊重原创,博主保留追究权)https://www.cnblogs.com/cnb-yuchen/p/18251310出自【进步*于辰的博客】参考笔记三,P53.1。目录1、介绍2、三种VMOptions最后1、介绍大家可能没注意过此注解,我从JDK源码中摘取一段:@CallerSensitivepublic......