1 / 10

More problems

More problems. Calculate. Write Java code that defines a real number called A, and gives it the value of 3.2. Then define an additional number with the value of the A 2 . And finally define an additional number with the value of A 3. Go figure. Write code that defines 3 numbers.

Download Presentation

More problems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. More problems

  2. Calculate. • Write Java code that defines a real number called A, and gives it the value of 3.2. • Then define an additional number with the value of the A2. • And finally define an additional number with the value of A3.

  3. Go figure. • Write code that defines 3 numbers. • Next, calculate their sum and product. • It should then output the sum and product.

  4. Write a program that calculates late fees on a movie rental. • The program reads the number of days the movie has been rented. • Up to 3 days is a regular rental, no fee. For the next week the fee goes up $3 each day. • Starting on the 10th day (i.e., a week late) there is a flat $20 fee that never changes. (from http://www.ccs.neu.edu/home/tov/course/cs2500/assigns/1.html)

  5. Distance and time. • Write code that, given an integer that represents distance in miles, will calculate and output the time (in hours) it takes to travel that distance when going 60 MPH. (from http://www.ccs.neu.edu/home/tov/course/cs2500/assigns/1.html)

  6. Time and distance. • Write code that, given an integer representing time (in minutes), will calculate and output the distance traveled when going 70 MPH, rounding up to whole miles. (from http://www.ccs.neu.edu/home/tov/course/cs2500/assigns/1.html)

  7. Taxi. • The Philadelphia Parking Authority currently regulates taxi fares in Philadelphia (http://www.philly-taxi.com/fares.htm). • Rates in the City of Philadelphia are as follows: • First 1/10 mile (flag drop) or fraction thereof: $2.70 • Each additional 1/10 mile or fraction thereof: $0.23 • Each 37.6 seconds of wait time: $0.23

  8. Income. • To supplement my meager teaching income*, I shovel snow for some of my neighbors. For shoveling a sidewalk and driveway, I charge each neighbor $10 per job plus $5 per inch of snowfall to be shoveled. • How much do I get paid if I shovel for one neighbor after a storm that drops 1 inch of snow? What if 4 neighbors hire me after a blizzard puts down 14 inches? • Create a formula for calculating how much I earn if I shovel d inches of snow for each of n neighbors. • Use the formula and write code to calculate and output out how much I earn after an unlikely 4 feet of snow when hired by 12 neighbors. * from http://www.ccs.neu.edu/home/tov/course/cs2500/assigns/1.html

  9. Grades. • At the end of the course, your instructor will compute a numeric grade in the range 0 to 100, inclusive, for each student, and then convert that number to a letter grade. • Suppose your instructor will give an A for numeric grades of 90 and above, B for grades from 80 up to but not including 90, C for [70, 80), D for [60, 70), and F for [0, 60). • Write code that asks the instructor for a score, and outputs the corresponding letter grade.

  10. Numbers. • Write code that defines 3 different numbers. • It should then output the numbers in order from smallest to largest.

More Related