Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Introduction to Computer Science Skip to Main Content Home Syllabus Lectures Assignments Exams Staff Tutors Calendar Rutgers Home SAS CS Introduction to Computer Science Computer Science Department Home Syllabus Lectures Assignments Exams Staff Tutors Calendar Conditionals and Loops – 60 course points The purpose of this assignment is to practice conditionals and loops.  Refer to our Programming Assignments FAQ for instructions on how to install VScode, how to use the command line and how to submit your assignments. Programming Write 3 programs and submit on Autolab. We provide this zip file containing LargestOfFive.java, CheckDigit.java, and RandomWalker.java. For each problem update and submit the corresponding file. Observe the following rules: DO NOT add any import statements DO NOT add the project statement DO NOT change the class name DO NOT change the headers of ANY of the given methods DO NOT add any new class fields DO NOT use System.exit() ONLY print the result as specified by each problem. DO NOT print other messages, follow the examples for each problem. Largest of five (20 points). Write an algorithm that read 5 distinct integers and displays the largest value. Assume the input values are distinct integers. java LargestOfFive 17 23 5 1 6 23 java LargestOfFive 8 3 -8 4 1 8 Check digit  (30 points). Write a program CheckDigit.java that takes a 12 or 13-digit long as a command-line argument and displays the digit computed as follows: Take for an example the number 048231312622 Sum every other digit of the code, starting from the right.  In the example, that is 2 + 6 + 1 + 1 + 2 + 4 = 16.  Discard the tens digit and keep the ones digit, 6.  Start with the second to last digit and do the same thing.  Sum the digits, discard the tens digit and keep the ones digit.  In this example this is 2 + 2 + 3 + 3 + 8 + 0=18.  Discarding the 10 leaves 8.  Multiply this number by 3 and again discard the tens digit.  8×3 = 24, leaving 4. Add the numbers from steps 1 and 2.  Again drop the tens digit.  6 + 4 = 10, leaving the digit 0 (zero). Hint 1: the maximum value that can be stored in an integer variable is 2147483647 which is only 10 digits long. To read a 12 or 13-digit integer from command line argument you will need to store it in a long variable. Use: long number = Long.parseLong(args[0]); to read a long from the command line. Hint 2: to extract the rightmost digit of a number use the modulus operator. Hint 3: to remove the rightmost digit of a number use the integer division by 10 Hint 4: for full credit use a loop to compute the sums Assume the input value used to test your program is a 12 or 13-digit positive integer.  java CheckDigit 048231312622 0 java CheckDigit 9780470454310 8 Two-dimensional random walk (10 points). A two-dimensional random walk simulates the behavior of a particle moving in a grid of points. At each step, the random walker moves north, south, east, or west with probability equal to 1/4, independent of previous moves. Write a program RandomWalker.java that takes an int command-line argument n and simulates the motion of a random walk for n steps. Print the location at each step (including the starting point), treating the starting point as the origin (0, 0). Also, print the square of the final squared Euclidean distance from the origin as double. Note: you do not need arrays for this problem, just keep track of the x and y coordinates during the random walk. java RandomWalker 20 (0,0) (0,1) (-1,1) (-1,2) (0,2) (1,2) (1,3) (0,3) (-1,3) (-2,3) (-3,3) (-3,2) (-4,2) (-4,1) (-3,1) (-3,0) (-4,0) (-4,-1) (-3,-1) (-3,-2) (-3,-3) Squared distance = 18.0 Before submission Collaboration policy. Read our collaboration policy here. Update @author. Update the @author tag of the files with your name, email and netid. Submitting the assignment. Submit LargestOfFive.java, CheckDigit.java, and RandomWalker.java separately via the web submission system called Autolab. To do this, click the Assignments link from the course website; click the Submit link for that assignment. Getting help If anything is unclear, don’t hesitate to drop by office hours or post a question on Piazza. Find instructors office hours by clicking the Staff  link from the course website. In addition to office hours we have the CAVE (Collaborative Academic Versatile Environment), a community space staffed with lab assistants which are undergraduate students further along the CS major to answer questions. Connect with Rutgers Rutgers Home Rutgers Today myRutgers Academic Calendar Calendar of Events SAS Events Explore SAS Departments & Degree-Granting Programs Other Instructional Programs Majors & Minors Research Programs, Centers, & Institutes International Programs Division of Life Sciences Explore CS We are Hiring! Research News Events Resources Search CS Home Back to Top Copyright 2020, Rutgers, The State University of New Jersey. All rights reserved. Rutgers is an equal access/equal opportunity institution. Individuals with disabilities are encouraged to direct suggestions, comments, or complaints concerning any accessibility issues with Rutgers web sites to: accessibility@rutgers.edu or complete the Report Accessibility Barrier or Provide Feedback Form.