Computer Science 202
Introduction to Programming
Fall 2013, The College of Saint Rose
Agenda
Write a Java application in a class MilesPerGallon whose
main method computes miles per gallon (miles driven divided by
gallons consumed) from values read in from the keyboard using a
Scanner. This is very similar to the area of a rectangle
example, except that we want to work with floating point numbers.
This means our variables should be of type double instead of
int and we will read in double values from a Scanner
using the nextDouble method instead of nextInt. Also,
division is accomplished using the /
operator.
Please submit only the file MilesPerGallon.java in Submission Box under "InClass10" before you leave class.
Due at the start of class, Tuesday, October 1.
Please submit answers to these questions in Submission Box under "LA10" by the start of our next class. We will discuss these questions at the start of class, so no late submissions are accepted. Please be sure that your name is clearly indicated in all submissions.
Write a Java application in a class AverageOf3 whose main method computes the average of 3 int values that you read from the keyboard. Submit only your file AverageOf3.java. (5 points)
Examples