代写file I/O作业、代写java Scanner I/O程序、代写java编程作业、代做java实验报告

日期:2018-09-05 03:40

?Objectives

oCreate a program that reads a file and stores all integers contained in that file.

oTo get practice in using Java programming concepts:

?Program arguments, file I/O, methods, arrays, wrapper objects, control structures

?Related SLOs

oUse standard libraries or packages

oProduce robust and secure programs using exception handling and extensive program testing.

?Instructions

oDue to the nature of this assignment, you should use wrapper objects instead of primitives.

oDownload the start file for this assignment: LastnameFirstname01.java

oAlso download the following files to the same folder you will be saving your Java program for this assignment:

?electricity.txt, notable.txt, 1000.txt

oOpen LastnameFirstname01.java in jGRASP, change Lastname and Firstname to your own last and first name.

oSave the file and choose the option to Rename and Save.

oChange the comments at the top as appropriate.

oFor the main(), ensure the following:

?The program will take in exactly 1 program argument, which will be a filename.

?Ensure there is exactly 1 program argument, otherwise the program should terminate with a meaningful message to the user.

oFor the readFileReturnIntegers() method:

?This method will open a file handle to the filename parameter and store all integers contained in the file in an array and return that array.

?Use the array already created in the start file to store all integers being read in.

?Create the necessary File and Scanner variables to read in a file.

?Note that you will need to catch FileNotFoundException when a Scanner object is created using a File object.

?While reading the file, you will need to use the hasNextLine(), and next() methods.

?See the Scanner Class API for more details on Scanner methods.

?Note: You will be using next() instead of nextLine(). next() grabs one word at a time whereas nextLine() grabs an entire line at once.

?Loop through the file using the hasNextLine() method of your Scanner variable.

?Use the next() to get one word from the file, and store the word in a String variable. Then use the static method Integer.parseInt() to convert the String into an integer and store the integer in the array.

?You will need an integer variable that represents the index number of the array and increment it each time you store an integer in the array.

?If it is NOT an integer, your program will throw a NumberFormatException.

?Use another try/catch block to determine which words are integers and which are not.

?You will also need to catch NoSuchElementException for blank lines in the file.

?Both catch blocks may be empty and not contain any code since the program is only concerned with integers and should continue until the end of the file.

?A rough rundown of populating the array is as follows:

?while the file has lines:

?  read in a word from the file;

?  attempt to convert that word into an integer;

?  store that integer in the array;

?  When a NumberFormatException occurs, do nothing since that word was not an integer

When a NoSuchElementException occurs due to a newline, do nothing since that is not an integer

oFor the printArrayAndIntegerCount() method:

?Print the name of the file and the number of integers in the file, and print all of the integers that are stored in the array.

?Your output should be similar to the output below.

?There will be null values in the array if the array was not filled up completely. As you loop through the array, use an if-statement to check if the value is not null, that is, =! null

?I recommend building a string that contains all of the information, then print that string at the end of the method.

oThe main() method should be very short, as it only has error checking for program arguments and two method calls.

oRun your program with the example .txt files as a program argument.

oBe sure your code is commented and follows the coding standard for the class.

?Example Output (using each of the .txt files)

java程序设计实验报告代写_代写file I/O作业、代写java Scanner I/O程序、代写java编程作业、代做java实验报告...相关推荐

  1. java程序设计及实践实践代码_杭+新闻:姚争为老师把程序设计讲“活”了,满是代码的枯燥课程被学生“秒杀”...

    通讯员 陈鑫 杨鹏飞 记者 方秀芬 作为专业选修课,Java程序设计和Web程序设计,这两门满是代码的课程,看似很枯燥,但在杭师大信息科学与工程学院却爆红,每学期都遭"秒杀",以前 ...

  2. 大学生java考试题库6_《JAVA程序设计》期末考试试题_(六)

    <JAVA程序设计>期末考试试题 (六) 一.填空题 1.定义类的保留字是( class ),定义接口的保留字是( interface ). 2.Socket通常也称为 ( 套接字 ),用 ...

  3. Java程序设计当中包的使用_【学习笔记】 唐大仕—Java程序设计 第4讲 类、包和接口之4.2 类的继承...

    [学习笔记] 唐大仕-Java程序设计 第4讲 类.包和接口之4.2 类的继承 super的使用 1.使用super访问父类的域和方法 注意:正是由于继承,使用this可以访问父类的域和方法.但是有时 ...

  4. java程序设计雷电游戏设计步骤_基于Java的飞机雷电射击游戏的设计任务书

    主要参考文献(资料): [1] Java 2游戏编程[M]. 清华大学出版社 , (美)ThomasPetchel著, 2005 [2] Java游戏引擎的开发与实现[J]. 何依林. 无线互联科技. ...

  5. 我的世界java百度什么电脑玩好_【我的世界】为了在龙芯电脑上玩Minecraft(我的世界)我做了什么_玩得好游戏攻略...

    为了在龙芯上玩Minecraft,拼了!先上跑起来的视频. 作为多年的Minecraft玩家,这个残余游戏消磨了我多量的时间.于是想着Minecraft Java版要是能在龙芯上跑起来就好了. 冷假前 ...

  6. python乘法符号手写_利用Python自动生成小学生加减乘除口算考试题卷,不再为手写算术题烦恼!...

    还在为给孩子抄各种各样的口算题而烦恼?孩子上小学一年级之后,加减乘除的口算就要开始练习了,老师肯定会让家长出题.所以我们当家长的,要提前准备一下,就利用Python开发了一套自动生成小学生口算题的小应 ...

  7. java delegate怎么写_美团面试官:你说你们公司的Mybatis分页插件是你写的,给我说说它的设计原理?...

    来源:http://my.oschina.net/zudajun 大多数框架,都支持插件,用户可通过编写插件来自行扩展功能,Mybatis也不例外. 我们从插件配置.插件编写.插件运行原理.插件注册与 ...

  8. 实验方法怎么写_四年级我的动物朋友作文,《小仓鼠》是怎么写出来的,有方法...

    对同学们来说,写动物的作文应该比较容易些,因为每个同学都喜欢小动物,都仔细地观察过小动物.而且,这篇作文的要求,比较简单,课本上只是让我们向别人介绍一下自己的动物朋友,这样大家就可以自由发挥,各显其能 ...

  9. 参考文献起止页码怎么写_参考文献是图书,怎么标注页码啊,用到哪页就写哪页吗(⊙_⊙?)...

    展开全部 书籍(专著)作文献类型标识为M,引用的页码起始页62616964757a686964616fe4b893e5b19e31333431363564标在最后,写引用处的起始页码就可以. 书籍作参 ...

  10. java冒泡排序找最大的值_(13)數組操作:遍歷、輸出最大值、冒泡排序、選擇排序,java已有的排序方法、折半查找...

    1.數組遍歷 /* * 獲取數組中元素,遍歷 */ int []y=new y[3]; for(int i=0;i { System.out.println("y["+i+&quo ...

最新文章

  1. [导入]JavaScript 滑动条效果
  2. G4Sui老师的pair project(197)
  3. PostgreSQL免安装部署方法
  4. SAP采购订单抬头、行项目屏幕增强的两种方法
  5. UVA1354天平难题 枚举二叉树
  6. C# 对象与JSON串互相转换
  7. python之实现从ftp下载文件到本地
  8. input type:text输入框点击输入,文字消失
  9. 【华为云技术分享】STM32L476移植华为LiteOS系列教程---开发前的准备 2
  10. 资深架构师谈云原生生态的基石Kubernetes
  11. Active Directory系列之二:部署第一个域
  12. Response.End方法
  13. 黑苹果smbios机型选择_黑苹果注入三码洗白教程
  14. U盘中了磁碟机病毒怎么办
  15. 一阶锁相环的FPGA实现(基于quartus+matlab)
  16. mysql phpmyadmin 报403错误_phpmyadmin出现403错误怎么办?
  17. 安卓开发 高德地图定位的封装 十分钟上手
  18. 服务器有固态盘系统安装,服务器有装固态硬盘吗
  19. 仿真软件proteus构建七段数码管显示数字0-9实验
  20. 3dmax:3dmax的软件右边栏常用修改器(Cloth修改器、车削、倒角/剖面、对称、FFD长方体/圆柱体、Gizmo、规格化样条线、挤出 、路径、扭曲、晶格、壳、拉伸)之详细攻略

热门文章

  1. 【WinForm】关于截图识别数字并计算的桌面程序实现方案
  2. android hook方法替换,Android Hook入门教程
  3. VirtualBox报错:不能为虚拟电脑XXX打开一个新任务
  4. 大学寒假这样过,过完惊艳所有人,不只是你的宿友,mysql基础教程西泽pdf
  5. dell文件服务器连接,配置DELL MD3200存储服务器连接到多台主机
  6. cmake rpath Makefile rapth
  7. 第一章:电商及商品系统概述
  8. 【啃书】《智能优化算法及其MATLAB实例》例6.1基本粒子群算法进行sphere函数寻优
  9. 计算机dns怎么设置方法,电脑的dns怎么设置具体方法
  10. OpenWrt之DNS设置