CSCI 1530 Computer Principles and Java Programming Assignment 3

$30.00

Download Details:

  • Name: Assignment-3-bhklqs.zip
  • Type: zip
  • Size: 173.52 KB

Category:

Description

5/5 - (1 vote)

Problem Solving with Java Programming Aim: 1. screen formatting. 2. practise problem solving. 3. practice using branching (if-else) and repetition (while/for/do-while) statements. 1. In the Year of the Pig, let’s try figuring out how many animals are there in a party. 2. Create a NEW NetBeans Project ProblemSolver and a new Java class ProblemSolver. Type your name, student ID and declaration statement clearly at the top comment block of the file ProblemSolver.java. /** * CSCI1530 Assignment 3 Problem Solving * Aim: problem solving with Java using branching and repetition statements * * Declaration: . . . * Student Name: xxx * Student ID : xxx * */ 3. This exercise makes use of the generate-and-test brute-force problem solving technique. Here is a sample run (with user inputs in RED): *** ProblemSolver *** There are at most 20 animals. A pig has 1 head, no wing, 4 legs. A duck has 1 head, 2 wings, 2 legs. A dragon has 3 heads, 2 wings, 4 legs. How many heads? 1 How many wings? 2 How many legs? 2 There are 0 pigs, 1 ducks, 0 dragons. Pigs : Ducks :* Dragons: Legend :12345678901234567890 Try again (enter 1 for yes; other int to quit)? 1 *** ProblemSolver *** There are at most 20 animals. A pig has 1 head, no wing, 4 legs. A duck has 1 head, 2 wings, 2 legs. A dragon has 3 heads, 2 wings, 4 legs. How many heads? 21 How many wings? 0 How many legs? 84 No solution. Try again (enter 1 for yes; other int to quit)? 1  *** ProblemSolver *** There are at most 20 animals. A pig has 1 head, no wing, 4 legs. A duck has 1 head, 2 wings, 2 legs. A dragon has 3 heads, 2 wings, 4 legs. How many heads? 34 How many wings? 22 How many legs? 72 There are 9 pigs, 4 ducks, 7 dragons. Pigs :********* Ducks :**** Dragons:******* Legend :12345678901234567890 Try again (enter 1 for yes; other int to quit)? 0 4. The properties of the three animals, pig, duck and dragon are fixed. There are at most 20 animals in a party. 5. A user inputs the number of heads, wings and legs observed. The program shall solve the problem and print a set of integer results in the form of a statement, “There are …”, as well as a horizontal bar chart with a simple legend. If the problem is unsolvable, print “No solution.” 6. Let the user try again after each problem-solution session, until the user wants to quit. 7. We assume all user inputs are valid integers. Solutions are integers too. 8. To simplify the task and the requirements, always adopt plural animal word form in the user prompts and result outputs. Submission: 1. Zip the whole NetBeans project ProblemSolver and Upload a single ZIP archive ProblemSolver.zip via Blackboard assignment collection box. 2. Remember to click “Submit”. Marking Scheme and Notes: 1. The submitted program should be free of any typing mistakes, compilation errors and warnings. 2. Comment/remark, indentation, style are under assessment in every programming assignments unless specified otherwise. This program gives you an example of a well-formatted source file. Variable naming, proper indentation for code blocks and adequate comments are important. 3. Marker will test your programs vigorously with various inputs. You should test run your own programs properly with different user input scenarios. 4. Remember to do your submission before 23:59 p.m. of the due date. No late submission would be accepted. 5. If you submit multiple times, ONLY the content and time-stamp of the latest one would be counted. We ONLY take into account the last submission. University Guideline for Plagiarism Attention is drawn to University policy and regulations on honesty in academic work, and to the disciplinary guidelines and procedures applicable to breaches of such policy and regulations. Details may be found at http://www.cuhk.edu.hk/policy/academichonesty/. With each assignment, students will be required to submit a statement that they are aware of these policies, regulations, guidelines and procedures.