2 Replies - 1550 Views - Last Post: 14 January 2010 - 03:33 PM Rate Topic: -----

#1 Patback1608  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-January 10

problem with writing racetrack.java

Posted 14 January 2010 - 12:11 PM

this program was assigned to me but i don't even know how to start it. It would be great if someone could help out.

A racetrack is formed by two rectangles, an outer rectangle (the track) and an inner rectangle (the field). The outer rectangle has a length of L and width of W. The inner rectangle has a length i (where i must be less than L) and a width of m
(where m must be less than W).

Write a program called racetrack.java that will accept as input the test data below. This input will be entered using a loop and the three pieces of data: length and width of the track and the length of the inner rectangle will be used. The program should edit (check) that the input meets the following criteria: all input must be positive integers, L, W, and i are less than 300, and m, when calculated, is less than W.

If the following criteria is not met, display an error for those measurements and continue accepting data from the user till all data is exhausted.

If it is met, you will provide the following as output:
the measurements of the track and the field, the area of the track, the area of the
field, the cost of paving the difference of the areas(the inner rectangle
will not be paved). The cost per square foot is $8.00. All calculations should be
rounded to the nearest hundredths digit if necessary.

Test data 1: L=200, W=180, i=160
2: L=220, W=180, i=170
3: L=310, W=200, i=160
4: L=190, W=170, i=200
5: L=200, W=300, i=160
6: L=-200, W=180, i=160 ERROR
7: L=200, W=-180, i=160 ERROR
8: L=200, W=180, i=-160 ERROR
9: L=0, W=0, i=0 ERROR
10: L=190, W = 170, i = -200 ERROR
11: L=200, W=120, i=100

Testing Table This must be submitted with a copy of your program on the due date.

L | W | I | m | Track | Field Difference Cost
| |
|
Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: problem with writing racetrack.java

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10665
  • View blog
  • Posts: 39,608
  • Joined: 27-December 08

Re: problem with writing racetrack.java

Posted 14 January 2010 - 12:53 PM

You might consider using the Scanner class to get the input. Also, you can use System.out.printf() to format your output, which includes rounding digits.

If you need more help, feel free to post. However, remember to include your efforts. We can't be of much more help, really, until we see some effort.

Good luck! :)
Was This Post Helpful? 0
  • +
  • -

#3 Patback1608  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-January 10

Re: problem with writing racetrack.java

Posted 14 January 2010 - 03:33 PM

Thank you for the advice.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1