Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CSE 174 - Spring 2022

Lab 4 - Number Converter

Description: You will build a program that will take an integer (0 or greater) from the user and     classify it based on a set of criteria. Different numbers are classified in different ways, so you will need to have some decision making in your code.

Required Skills and Outcomes:

To complete this assignment, you will need to:

●   obtain user input to get the input number

●   use conditionals to classify the number as 0, odd, or even

●   use conditionals to determine additional divisors of the input number

●   apply nested conditional statements to reduce complexity of conditions

●   use a ternary operator to assign values based on a condition

●   display the classification results to the user

Directions:

1.  You first need to get the input from the user; you can safely assume the user will provide an integer in the range of 0 to the maximum value an integer can hold.

2.  You will need to classify the number based on the following five categories:

a.  Your number is 0.

b.  Your number is odd but not divisible by 3 or 5.

c.   Your number is odd and also divisible by 3 or 5.

d.  Your number is even but not divisible by 4 or 6.

e.  Your number is even and also divisible by 4 or 6.

3.   While it is possible to perform this classification without it, you must use nested

if-statements to classify the numbers using the above categories. Consider how you would group your statements to avoid complex conditional statements.

4.   Further, there is another classification that needs to be presented to the user regarding the largeness of their number. For our program, a number is large if it is 1000 or more.

a.  This classification must use a ternary operator to determine the largeness and store that result to display to the user.

Example Runs

Use the following examples to help ensure your program is running correctly, producing the right result, and printing the right output to the console and file. (Note: the output files should have      the same content as the console, assuming you have written anything to the file)

Note: the orange text is input provided by the user. Also recall that the output in CODE may       appear slightly different than the output in jGRASP (related to line breaks); the examples below are how it should appear in jGRASP.

Example 1

Console Output:

 

Your number is even and also

Further, this is not a large

Example 2

Console Output:

 

Your number is odd and is also divisible

Further, this is a large number .

Example 3

 

an integer (0 or greater) to classify: 29

odd but not divisible by 3 or 5 .

Further, this is not a large number .

Example 4

Console Output:

 

Your number is 0 .

Further, this is not a large

Submission

You will submit your assignment using the CODE plugin.

There will be several visible test cases (including those provided above) as well as some hidden test cases. Your program must pass all of the visible tests in order to submit. The hidden test      cases are not required for submission, but are required for full credit.

Grading Rubric - Lab 4 (20 Points)

Criteria

Description

Full Credit

Partial Credit

Visible Tests

Your program must pass all 6 visible tests in order to submit, if it fails any test, you will not be able to submit.

8

 

Hidden Tests

There are 4 hidden tests that you  cannot see the inputs or expected outputs. To achieve full credit you  must pass all hidden tests.

4

Each test failed will deduct 1 point.

Specific           Conditional     Requirements

This lab can be solved in several    ways to achieve the required          outputs, however, you are required to use nested if-statements and a   ternary operator as described.

4

Each departure from    the required                 conditional statements will deduct 2 points.

Style

You must submit code with no style errors. CODE will check your style   for you, but will still accept                submissions with errors. To achieve full credit, you must have 0 style      errors.

2

Each style error           present will deduct 0.5 points, up to a              maximum of 4              deductions.

Comments

Your code must be well                     documented. This includes                comments at the top of your code     with the usual details, as well as       comments in the body of your code  describing what is done, and any      other required comments covered in class. To achieve full credit, all          comments must be present.

2

Each missing              comment element will result in a 0.5 point     deduction, up to a       maximum of 4             deductions.