# CSC 120Programming Project #4Due Dates:Part 1:by 11:55pmMonday, April 3, 2023Part 2:by 11:55pmMonday, April 10, 2023Objectives:•To analyze a problem and implement its...

CSC 120

Programming Project #4

Due Dates:

Part 1:

by 11:55pm

Monday, April 3, 2023

Part 2:

by 11:55pm

Monday, April 10, 2023

Objectives:

To analyze a problem and implement its solution

To practice writing a data type class and if statements

To gain experience writing code to test a data type class

The Problem:

You have been hired by a school district to write a program for their 4th

grade students who need to practice long division. The district has indicated that although all students have been taught long division through a divisor of 12 and a dividend of 144, students abilities vary. They would like the student to be able to indicate the starting difficulty, easy, moderate, or difficult and then have the program adapt the difficulty based upon the student’s performance.

Level 1 (easy): divisor in the range 1-4, dividend in the range

divisor-20 – for example,

 Divisor Dividend 1 1-20 2 2-20 3 3-20 4 4-20

Level 2 (moderate): divisor in the range 5-7, dividend in the range 21 -50 – for example,

 Divisor Dividend 5 21-50 6 21-50 7 21-50

Level 3 (difficult): divisor in the range 8-12, dividend in the range (divisor * 7)

-144 – for example,

 Divisor Dividend 8 56-144 9 63-144 10 70-144 11 77-144 12 84-144

The student will first be asked to find the quotient. If they get it correct, then they will be asked for the remainder. If the student can correctly determine both the quotient and the remainder then the difficulty level should automatically increase. If the student gets the quotient correct but not the remainder the difficulty level does not change. If the student gets the quotient incorrect the difficulty level should automatically decrease. At the end of the program the student should be told how many questions they got completely correct.

Start Eclipse & Create a New Project

Create a new project,

proj4

, which contains 2 classes,

Question

and

Project4

. Be sure to name the package

proj4

when creating the classes and that you use proper capitalization for the class names.

Writing Java Statements – The Question Class

The purpose of the Question class is to generate a dividend and divisor based upon the difficulty level specified.

Background – The Random Class

To complete this project you will be using the Random class that is provided by Java. The Random class can be accessed by including the following import statement.

import java.util.Random;

To create a Random object use the default constructor. For example,

# Random randGen = new Random();

The nextInt method accepts an integer value and the method returns a random integer between 0 and the value specified minus 1. For example, if the method is sent the number 5, the method will return a value in the range 0 – 4 (inclusive).

# randNum = randGen.nextInt(5);

The Dice class you wrote in Lab #6 used a Random object to generate a value in the range 1 – 6 (inclusive) with the following statement.

# die1 = randGen.nextInt(6) + 1;

Specifications:

Part 1 – due Monday, April 3

rd

:

The Question class needs:

2 instance variables:

the dividend and divisor to be used in the long division equation

A parameterized constructor:

the parameterized constructor will accept a value to indicate the level of difficulty and it should generate a dividend and divisor as specified by the school district (it must meet the specifications above) –

comment your code to explain how your statement works to generate the divisor and divedend in the proper ranges

A

toString

method that returns a String containing the division question (but not the answer). The format should be dividend, /, divisor and an equal sign. You should decide what spacing you think works best

For example,

# 5/2=

## 120 / 9 =

A

determineQuotient

method which calculates and returns the quotient. The answer should

not

be stored as an instance variable.

A

determineRemainder

method which calculates and returns the remainder. The answer should

not

be stored as an instance variable.

You do not need to write accessor or mutator methods for this project.

Testing the Question class:

Once you have the Question class written, test your code in the application class to make sure it works properly. Recall, your application class will need a main method. Running the program once will not give you enough information to let you know if it is working properly. You should create and display 10 easy questions, 10 moderate questions and 10 difficult questions to make sure that the numbers are in the specified ranges and the quotients and remainders are being calculated properly. For each question it should display a label with the question #, the question and both the quotient and remainder for the user to see.

Sample output:

Testing 10 easy questions:

Q1: 6/4= the quotient is: 1 and the remainder is: 2

Q2: 6/4= the quotient is: 1 and the remainder is: 2

Q3: 2/2= the quotient is: 1 and the remainder is: 0

Q4: 9/1= the quotient is: 9 and the remainder is: 0

Q5: 6/4= the quotient is: 1 and the remainder is: 2

Q6: 6/2= the quotient is: 3 and the remainder is: 0

Q7: 6/3= the quotient is: 2 and the remainder is: 0

Q8: 10/2= the quotient is: 5 and the remainder is: 0

Q9: 17/1= the quotient is: 17 and the remainder is: 0

Q10: 11/4= the quotient is: 2 and the remainder is: 3

Testing 10 moderate questions:

Q11: 44/7= the quotient is: 6 and the remainder is: 2

Q12: 21/6= the quotient is: 3 and the remainder is: 3

Q13: 40/5= the quotient is: 8 and the remainder is: 0

Q14: 35/5= the quotient is: 7 and the remainder is: 0

Q15: 32/7= the quotient is: 4 and the remainder is: 4

Q16: 34/6= the quotient is: 5 and the remainder is: 4

Q17: 30/5= the quotient is: 6 and the remainder is: 0

Q18: 32/6= the quotient is: 5 and the remainder is: 2

Q19: 31/7= the quotient is: 4 and the remainder is: 3

Q20: 46/6= the quotient is: 7 and the remainder is: 4

Testing 10 difficult questions:

Q21: 82/8= the quotient is: 10 and the remainder is: 2

Q22: 94/8= the quotient is: 11 and the remainder is: 6

Q23: 116/8= the quotient is: 14 and the remainder is: 4

Q24: 105/12= the quotient is: 8 and the remainder is: 9

Q25: 96/9= the quotient is: 10 and the remainder is: 6

Q26: 93/12= the quotient is: 7 and the remainder is: 9

Q27: 80/8= the quotient is: 10 and the remainder is: 0

Q28: 74/8= the quotient is: 9 and the remainder is: 2 Q29: 101/10= the quotient is: 10 and the remainder is: 1

Q30: 95/12= the quotient is: 7 and the remainder is: 11

Part 2 – due Monday, April 10

th

:

Writing the Math game in the application class

Your prior testing was to verify that the Question class worked properly. You can comment out or delete your testing code.

The application class should use the Question class to create a math game for children to play which will ask the student 10 long division questions. The game will adapt the level of question based upon the student’s answer.

The game should:

Ask the student what type of question they want to start with, easy, moderate or difficult. For example,

After the student has selected a difficulty level, your program should create a Question and ask the student to determine the quotient. For example,

If the quotient is correct, provide the student with a message letting them know then ask them what the remainder is. For example,

If the remainder is correct, provide the student with a congratulatory message and increase the difficulty level (the max difficulty is 3). For example,

If the remainder is incorrect, provide the student with a message that includes the correct remainder and keep the difficulty level should not change. For example,

If the quotient is incorrect, provide the student with a message that includes the correct quotient and decrease (the min difficulty is 1). For example,

The game must keep track of the number of questions the student gets completely correct. addition questions the student gets correct and incorrect as well as the number of subtraction questions the student answers correctly and incorrectly. Use 4 different counters to keep track of this information.

The game must keep track of the number of questions the student got completely correct and display it at the end of the game.

See below for a sample execution.

What type of question do you want to start with: easy (1), moderate (2) or difficult (3)?

1

Q1: Level: 1

What's the quotient for: 15/2=

7

Congrats!

What's the remainder for: 15/2=

1

Woo hoo! You got it right!

Let's try a harder question

Q2: Level: 2

What's the quotient for: 38/6=

6

Congrats!

What's the remainder for: 38/6=

2

Woo hoo! You got it right!

Let's try a harder question

Q3: Level: 3

What's the quotient for: 136/8=

17

Congrats!

What's the remainder for: 136/8=

0

Woo hoo! You got it right!

Q4: Level: 3

What's the quotient for: 85/11=

7

Congrats!

What's the remainder for: 85/11=

7

Sorry, that's not correct. The remainder for 85/11= is 8

Q5: Level: 3

What's the quotient for: 124/12=

12

Not quite. The quotient for 124/12= is 10

Let's try something easier

Q6: Level: 2

What's the quotient for: 50/7=

7

Congrats!

What's the remainder for: 50/7=

1

Woo hoo! You got it right!

Let's try a harder question

Q7: Level: 3

What's the quotient for: 126/9=

10

Not quite. The quotient for 126/9= is 14

Let's try something easier

Q8: Level: 2

What's the quotient for: 32/6=

6

Not quite. The quotient for 32/6= is 5

Let's try something easier

Q9: Level: 1

What's the quotient for: 19/2=

9

Congrats!

What's the remainder for: 19/2=

1

Woo hoo! You got it right!

Let's try a harder question

Q10: Level: 2

What's the quotient for: 23/5=

4

Congrats!

What's the remainder for: 23/5=

3

Woo hoo! You got it right! You got 5 completely correct

Citation/Cheating Policy:

This assignment is to be completed

individually

(not with your pair programming partner). It is intended to help you better understand data type classes and to build your problem-solving skills. You

are encouraged to

receive help from your instructor or from the Computer Learning Center in B225 if you have questions. Please do

not

ask another student for help. If you have questions about what constitutes cheating, please see the College’s Academic Dishonesty and Plagiarism Policy in the course syllabus and/or speak with your instructor.

Style/Coding/Documentation Requirements:

Neatness Counts!!! Proper indentation is required. Be consistent with your use of white space.

Make sure you have included comments describing what each portion of your program does.

Include blank lines in your output to make it easier to read.

Include a comment at the beginning of both your files that includes a

title

, a

description

of what that file does (this should be 2-3 sentences that explains what your program does as if you were talking to someone who doesn’t know anything about programming) and your name as the

author

. Be sure to keep the @author before your name.

Each constructor/method in the Question class should be preceded by a Javadoc comment (see Lab #5 for Javadoc format).

Submissions via codePost:

Upload your Question,java and Project4.java files to codePost under the proper Part of the Project #4 assignment.

Part 1:

Due by Monday, April 3rd

(-10 pts if not handed in by the due date) – feedback will be provided through codePost and should be used to make changes for part 2

Part 2:

Due by Monday, April 10th

Apr 01, 2023
SOLUTION.PDF

## Get Answer To This Question

### Submit New Assignment

Copy and Paste Your Assignment Here