Project 02 Solution

$35.00 $29.00

Your project files should be submitted to Web-CAT by the due date and time specified. In order to avoid a late penalty for the project, you must submit your completed code files to Web-CAT by 11:59 p.m. on the due date. If you are unable to submit via Web-CAT, you should e-mail your project Java…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Categorys:
Tags:

Description

5/5 – (2 votes)

Your project files should be submitted to Web-CAT by the due date and time specified. In order to avoid a late penalty for the project, you must submit your completed code files to Web-CAT by 11:59 p.m. on the due date. If you are unable to submit via Web-CAT, you should e-mail your project Java files in a zip file to your TA before the deadline.

Files to submit to Web-CAT:

  • ATM.java

  • SlopeIntercept.java

Specifications

Overview: You will write two programs this week. The first will calculate the number bills to be dispensed from an ATM and the second will computer the Y and X intercepts for line given the X and Y coordinates for two points on the line.

  • ATM.java

Requirements: An ATM manufacturer would like a program that allows the user to enter the amount of cash in whole dollars and then displays the number bills by denomination be dispensed if the limit of $300 is not exceeded.

Design: The ATM manufacturer would like the output to look as shown below when 400 is entered as the amount for one run and 279 is entered for another run.

Line number

Program output

1

Enter the amount: 400

2

Limit of $300 exceeded!

Line number

Program output

1

Enter the amount: 279

2

Bills by denomination:

3

$20: 13

4

$10: 1

5

$5:

1

6

$1:

4

7

$279 =

(13 * $20) + (1 * $10) + (1 * $5) + (4 * $1)

Your program must follow the above format with respect to the output. Note that lines 3 through 6 for the amount 279 begin with tab, which is set to three spaces in jGRASP (i.e., your output should use the escape sequence for a tab).

Code: In order to receive full credit for this assignment, you must calculate the number of each denomination and store the value in a variable. It is recommended as a practice that you do not modify input values once they are stored.

Page 1 of 3

Page 2 of 3

Test: You will be responsible for testing your program, and it is important to not rely only on the example above. Assume that the amount entered can be any integer greater than or equal to 0.

  • SlopeIntercept.java

Requirements: A program is needed that takes the x and y coordinates of two points as doubles and calculates the slope (if defined) of the line defined by the two points. The slope is only defined if the two x coordinates are not equal. If the slope is defined, the program calculates and prints the Y intercept and then further, if the slope is not 0, it calculates and prints the X intercept.

Design: The equations for finding the slope (where x1≠ x2) and the Y and X intercepts are as follows:

=

2

1

where x1 ≠ x2

2

1

= 1− ∗ 1

=−1∗

where slope ≠ 0; i. e. , y1 ≠ y2

Three examples of program output for the indicated input values are show below (you may replace everything in italics with your own words if desired):

Example #1

Line number

Program output

1

Enter the X and Y coordinates of starting point:

2

x1

= 3

3

y1

= 1

4

Enter the X and Y coordinates of ending point:

5

x2

= 4

6

y2

= 2

7

Slope: 1.0

8

Y intercept: -2.0

9

X intercept: 2.0

Note that lines 2, 3, 5, and 6 begin with tab, which is set to three spaces in jGRASP. Below is an example where slope is undefined.

Page 3 of 3

Example #2

Line number

Program output

1

Enter the X and Y coordinates of starting point:

2

x1

= 2

3

y1

= 4

4

Enter the X and Y coordinates of ending point:

5

x2

= 3

6

y2

= 4

7

Slope: 0.0

8

Y intercept: 4.0

9

X intercept: “undefined”

Example #3

Line number

Program output

1

Enter the X and Y coordinates of starting point:

2

x1

= 2

3

y1

= 5

4

Enter the X and Y coordinates of ending point:

5

x2

= 2

6

y2

= 9

7

Slope: “undefined”

Code: Your numeric variables should be of type double. Use an if-else statement to determine if x1 is equal to x2. If true, print a line indicating that the slope is undefined as shown in Example #3 above; if false, print value of the slope followed by the Y and X intercepts as shown in Example #1 above. Note that in Example #2, the X intercept was undefined since y1 is equal to y2.

Test: You are responsible for testing your program, and it is important to not rely only on the examples above. Remember that the input coordinates, slope, and the Y and X intercepts are doubles, so be sure to test both positive and negative values (with and without a decimal point) for the X and Y coordinates. You should use a calculator or jGRASP interactions to check your answers.

Grading

Web-CAT Submission: You must submit both “completed” programs to Web-CAT at the same time. Prior to submitting, be sure that your programs are working correctly and that have passed Checkstyle.

If you do not submit both programs at once, the submission will receive zero points for correctness. Activity 1 describes how to create a jGRASP project containing both of your files.

Page 3 of 3

Project 02 Solution
$35.00 $29.00