Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Lab Project 1 - Computer Science II | CSCI 1260, Study Guides, Projects, Research of Computer Science

Material Type: Project; Professor: Bailes; Class: Intro Computer Sci II; Subject: Computer & Information Science (CSCI); University: East Tennessee State University; Term: Unknown 1989;

Typology: Study Guides, Projects, Research

Pre 2010

Uploaded on 08/17/2009

koofers-user-810
koofers-user-810 🇺🇸

10 documents

1 / 7

Toggle sidebar

Related documents


Partial preview of the text

Download Lab Project 1 - Computer Science II | CSCI 1260 and more Study Guides, Projects, Research Computer Science in PDF only on Docsity! CSCI1260 Introduction to Computer Science II Lab Project 1 We wish to develop an application that will help individuals practice fraction arithmetic. The application will be command-line driven. The tables below demonstrate how the program should operate. You will also find a working JAR file of the application; use the application to guide your development. To run it, go to a command prompt and type java –jar jarfilename.jar The user will first be prompted for his or her name and then presented with his or her statistics and a menu as in the following. Please enter your name: Wayne Wayne, so far, you've answered 0 of 0 hard problem(s) correctly. Wayne, so far, you've answered 0 of 0 medium problem(s) correctly. Wayne, so far, you've answered 0 of 0 easy problem(s) correctly. 1 - Easy Problem 2 - Medium Problem 3 - Hard problem 4 - Exit Please make a selection (1-4): Option 1 generates an easy problem: 1 - Easy Problem 2 - Medium Problem 3 - Hard problem 4 - Exit Please make a selection (1-4):1 You have 3 attempt(s) left. What is 1/4 / 1/3? Enter the numerator : 3 Enter the denominator: 4 CORRECT! The correct answer is : 3/4 Wayne, so far, you've answered 0 of 0 hard problem(s) correctly. Wayne, so far, you've answered 0 of 0 medium problem(s) correctly. Wayne, so far, you've answered 1 of 1 easy problem(s) correctly. 1 - Easy Problem 2 - Medium Problem 3 - Hard problem 4 - Exit Please make a selection (1-4): Option 2 generates a medium problem: 1 - Easy Problem 2 - Medium Problem 3 - Hard problem 4 - Exit Please make a selection (1-4):2 You have 3 attempt(s) left. What is 7/7 - 4/9? Enter the numerator : 18 Enter the denominator: 42 Sorry, but you are incorrect! You have 2 attempt(s) left. What is 7/7 - 4/9? Enter the numerator : 39 Enter the denominator: 63 Sorry, but you are incorrect! You have 1 attempt(s) left. What is 7/7 - 4/9? Enter the numerator : 35 Enter the denominator: 63 CORRECT! The correct answer is : 35/63 Wayne, so far, you've answered 0 of 0 hard problem(s) correctly. Wayne, so far, you've answered 1 of 1 medium problem(s) correctly. Wayne, so far, you've answered 1 of 1 easy problem(s) correctly. 1 - Easy Problem 2 - Medium Problem 3 - Hard problem 4 - Exit Please make a selection (1-4): Option 3 generates a hard problem: 1 - Easy Problem 2 - Medium Problem 3 - Hard problem 4 - Exit Please make a selection (1-4):3 You have 3 attempt(s) left. What is 13/17 / 16/16? Enter the numerator : 13 Enter the denominator: 18 Sorry, but you are incorrect! You have 2 attempt(s) left. What is 13/17 / 16/16? Enter the numerator : 14 Enter the denominator: 19 Sorry, but you are incorrect! You have 1 attempt(s) left. What is 13/17 / 16/16? Enter the numerator : 19 Enter the denominator: 45 Sorry, but you are incorrect! The correct answer is : 208/272 Wayne, so far, you've answered 0 of 1 hard problem(s) correctly. Wayne, so far, you've answered 1 of 1 medium problem(s) correctly. Wayne, so far, you've answered 1 of 1 easy problem(s) correctly. 1 - Easy Problem h.reduceToLowestTerms(); System.out.println(h); // 1/2 CLASS: RATIONALNUMBERPROBLEM A rational number problem is composed of two rational numbers and an arithmetic operator, which is one of: Multiply (*), Divide (/), Add (+), or Subtract (-). You should use an enumeration to represent the operator: MULTIPLY, DIVIDE, ADD, and SUBTRACT. The rational number problem class has the following additional responsibilities:  It can return the answer to the problem as a rational number.  It can check if a given rational number is the correct answer to the problem.  It returns the problem as a String, with the toString() operation. Here is an example of the class in use: RationalNumber half = new RationalNumber(1, 2); RationalNumber third = new RationalNumber(1, 3); RationalNumberProblem problem = new RationalNumberProblem( half, RationalNumberProblem.ArithmeticOperator.MULTIPLY, third); RationalNumber answer = new RationalNumber(4, 5); System.out.println("What is " + problem + "?"); if(problem.isAnswerCorrect(answer)) { System.out.println("Correct!"); } else { System.out.println("Incorrect!"); System.out.println("The answer is " + problem.getAnswer()); } Here is the output of the above code snippet: What is 1/2 * 1/3? Incorrect! The answer is 1/6 CLASS: PROBLEMGENERATOR We now wish to generate random rational number problems. A rational number problem generator has the responsibility of generating rational number arithmetic problems at one of three levels: EASY, MEDIUM, and HARD. In an easy problem, the numerator is always 1 and the denominator is a random number in the range of 1 through 4. In a medium problem, the numerator is in the range 2 through 9 and the denominator is in the range 5 through 9. In a hard problem, the numerator and denominator are in the range of 10 through 20. In all three cases, the operator is randomly generated as one of: MULTIPLY, DIVIDE, ADD, or SUBTRACT. Here is an example of the class in use: RationalNumberProblem problem = ProblemGenerator.generateProblem(ProblemGenerator.DifficultyLevel.EASY); System.out.println("Easy problem: " + problem + "?"); problem = ProblemGenerator.generateProblem(ProblemGenerator.DifficultyLevel.MEDIUM); System.out.println("Medium problem: " + problem + "?"); problem = ProblemGenerator.generateProblem(ProblemGenerator.DifficultyLevel.HARD); System.out.println("Hard problem: " + problem + "?"); Here is one possible output: Easy problem: 1/3 * 1/4? Medium problem: 8/5 - 6/9? Hard problem: 16/14 + 11/11? Use the three classes you have created to design and code the application that is needed. You may have as many other classes as you feel appropriate. SUBMITTING THE FINAL PROJECT Submit the completed project via the Dropbox as described on the course fact sheet. For submission: 1. JUDE file showing the class diagram of the application. 2. Pseudocode design of the application. 3. Zipped source code of the Java files – that is, the .java files only. EVALUATION RUBRIC Criteria Points Awarded Comments The code is maintainable (30%) Code indented to standards (5) Code commented to standards (5) Internal comments used and used appropriately (5) Identifier names are meaningful (5) Constants used appropriately (5) Class diagram is correct (5) The solution is correct (70%) Pseudocode is appropriate (5) RationalNumber class is correct (10) RationalNumberProblem class is correct (10)  Composition properly implemented  Enumeration used properly ProblemGenerator class is correct (10)  Good use of instantiation  Appropriate implementation of EASY, MEDIUM, and HARD  Random number generation is appropriate The program compiles without warnings. (5) The program compiles with syntax errors (5) The program is functional (10) The program produces expected results (15) TOTAL
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved