讲解:Java:CSCI2110 Analyzing Data from a Road Traffic MeterJava、Java

根据两个测距仪传感器采集到的时间和车速数据,推测道路上的汽车型号。PurposeThe purpose of this assignment is to refresh your programming skills and get you programming as quickly as possible.As discussed in class and the first tutorial, for each problem you will be provided with a description of the problem and a JUnit test class to test your code. A similar JUnit test class will be used to evaluate your code. You can use Eclipse or other IDEs to run the JUnit test class to test your code.Your code must compile. If it does not compile, you will receive a 0 on the assignment.Problem: Analyzing Data from a Road Traffic MeterTo analyze how much traffic is on the street, city planners use a Road Traffic Meter, as shown in the figure below:The traffic meter consists of two air hoses lying across the lane of traffic. Every time the wheels of a vehicle roll over both hoses in quick succession, the meter logs the event as one axle of a vehicle. Two pieces of information are logged for each event: the time (in milliseconds) and the speed the axle was traveling at (in kilometers per hour). The traffic meter produces a log of axle events that look like this:97205795 51 97205995 52 97207123 45 97207347 44 ... where each line corresponds to a single axle event and is denoted by the time of crossing and speed.However, traffic planners need to know how many cars and heavy trucks are using the street. Your task is to write a program that processes the log and converts the log of axles to a log of cars and trucks that have crossed the traffic meter.Write a program called VehicleCounter.java that reads in a log of axles (as exemplified above) and outputs the corresponding list of cars and heavy trucks. Your VehicleCounter class must implement the provided TrafficReporter interface. This is because your program will be tested via this interface. The interface contains a single method:1public ArrayList computeTraffic(Scanner input);& This method must perform the required computation.InputThe method takes a Scanner object, which contains 0 or more lines of text from the log produced by a traffic meter. Each line denotes a single event of an axle crossing the traffic meter. Each line consists ofan integer of type long, denoting the time in milliseconds; andan integer of type int, denoting the speed of the axle in kilometers per hour.You may assume that there are no errors in the input.Hint: Use the Scanner object to easily parse the input by using the methods such as hasNextLong(), nextLong(), and nextInt(), on the Scanner object.SemanticsThe input log will contain a sequence of axles, corresponding to zero or more vehicles driving down the street. Your vehicle counter must distinguish between two classes of traffic:Cars and light trucks are vehicles that have exactly two axles, which are at least 186cm apart.Heavy trucks are vehicles that have at least three axles, with one or more close consecutive axles at the front and one or more close consecutive axles on the back. Two axles are close if they are less than 186cm apart.The distance between axles can be computed using the geJava代写:CSCI2110 Analyzing Data from a Road Traffic Meter代做Janeral formuladistance = speed * time where speed is the average of the two axle speeds and time is the positive difference between the arrival times of the two axles. Note: The speed of the axles is given in km/h, the time of arrival is given in milliseconds, and the minimum distance is in centimeters. You will need to convert the values to common units in order to get correct results.OutputThe method should return an ArrayList of Strings denoting the class of vehicle for each set of axles in the input log. If the axles correspond to the car or light truck, the corresponding String isT: Car or light truck and, if the axles in the input log correspond to a heavy truck, the corresponding String isT: Heavy truck, F R whereT is the time, rounded down to the nearest second, of the vehicle’s first axle crossing the traffic meter.F is the number of axles at the front of a heavy truck.R is the number of axles at the rear of a heavy truck.ExamplesBelow are a sequence of examples and the corresponding output.Sample Input502788 32 503612 33 503775 34 560933 37 561479 36 595629 41 596044 42 650172 56 650780 55 650878 54 650978 53 Sample Output502: Heavy truck, 1 2 560: Car or light truck 595: Car or light truck 650: Heavy truck, 1 3 Hints and SuggestionsYour code must compile. If it does not compile, you will receive a 0 on the assignment.Your code must be well commented and indented. Please see the Assignments section for this course on Brightspace for Code Style Guidelines.You may assume that all input will be correct. You do not need to handle incorrect input, for now.The problem in this assignment has a short solution (50 lines of code).Be sure to test your programs using the provided JUnit test class.GradingThe assignment will be graded based on three criteria:Functionality“Does it work according to specifications?”. This is determined in an auto- mated fashion by running your program on a number of inputs and ensuring that the outputs match the expected outputs. The score is determined based on the number of tests that your program passes. So, if your program passes t tests, you will receive T that proportion of the marks.Quality of Solution“Is it a good solution?” This considers whether the solution is correct, efficient, covers boundary conditions, does not have any obvious bugs, etc. This is determined by visual inspection of the code. Initially full marks are given to each solution and marks are deducted based on faults found in the solution.Code Clarity“Is it well written?” This considers whether the solution is properly formatted, well documented, and follows coding style guidelines.If your program does not compile, it is considered non-functional and of extremely poor quality, meaning you will receive 0 for the solution.What to Hand InSubmit the source files for your program in a zip file (.zip). You should have at least one source file: VehicleCounter.java. If you are using Eclipse, we recommend that you submit the entire project bundle. Submission is to be done via Brightspace. Your code must compile. If it does not compile, you will receive a 0 on the assignment.转自:http://ass.3daixie.com/2019011414390093.html

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,843评论 6 502
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,538评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 163,187评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,264评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,289评论 6 390
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,231评论 1 299
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,116评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,945评论 0 275
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,367评论 1 313
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,581评论 2 333
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,754评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,458评论 5 344
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,068评论 3 327
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,692评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,842评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,797评论 2 369
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,654评论 2 354

推荐阅读更多精彩内容

  • When Christian Haroldsen was six months old, preliminary ...
    杜芙Duff阅读 692评论 0 1
  • 缘份真是个奇妙的东西,从陌生到熟悉,一切都那么顺其自然水到渠成。就像我们俩注定会有故事,那么相似又那么互补。最喜欢...
    爱吃橙子的周周阅读 234评论 0 1
  • 六爻的学习,我首推古六爻,不推荐新派六爻,新派六爻掺杂了一些八字的东西,很乱, 先谈谈六爻发展史,六爻从古代最早就...
    柳暗花明aba阅读 2,636评论 0 2
  • 【全栈记】有半个月没有更新了,本打算以“周记”的方式记录自己的全栈学习过程,但并未做到,两周内我想了蛮多,学习前端...
    官清岁月阅读 489评论 0 3