Arrival Time Estimator Create a program that calculates the estimated hours and
ID: 3818521 • Letter: A
Question
Arrival Time Estimator
Create a program that calculates the estimated hours and minutes for a trip. This should include an estimated date/time of departure and an estimated date/time of arrival.
Arrival Time Estimator
Estimated date of departure (YYYY-MM-DD): 2016-11-23 Estimated time of departure (HH:MM AM/PM): 10:30 AM Enter miles: 200 Enter miles per hour: 65
Estimated travel time Hours: 3 Minutes: 5 Estimated date of arrival: 2016-11-23 Estimated time of arrival: 01:35 PM
Continue? (y/n): y
Estimated date of departure (YYYY-MM-DD): 2016-11-29 Estimated time of departure (HH:MM AM/PM): 11:15 PM Enter miles: 500 Enter miles per hour: 80 Estimated travel time Hours: 6 Minutes: 20
Estimated date of arrival: 2016-11-30 Estimated time of arrival: 05:35 AM
Continue? (y/n): n
Specifications For the date/time of departure and arrival, the program should use the YYYY-MM-DD format for dates and the HH:MM AM/PM format for times. For the miles and miles per hour, the program should only accept integer entries like 200 and 65. Assume that the user will enter valid data. This is for Python 3.x Add validation (error checking) and exception handling for all user entries. In other words, do not assume the user will enter valid data.
Explanation / Answer
import java.util.Scanner;
open class Calculator {
open static void main(String[] args) {
Scanner input = new Scanner(System.in);
Maths = new Maths();
twofold answer = 0;
twofold inputA, inputB;
scorch administrator;
boolean done = false;
while (done == false) {
System.out.print("Please enter your whole: ");
inputA = input.nextDouble();
administrator = input.next().charAt(0);
inputB = input.nextDouble();
switch (administrator) {
case '+': answer = Maths.add(inputA, inputB);
break;
case '- ': answer = Maths.subtract(inputA, inputB);
break;
case '*': answer = Maths.multiply(inputA, inputB);
break;
case '/': answer = Maths.divide(inputA, inputB);
break;
case '^': answer = Maths.power(inputA, inputB);
break;
}
System.out.println(answer);
}
input.close();
}
}
open class Maths {
twofold add(double a, twofold b) {
twofold answer = a+b;
return reply;
}
twofold subtract(double a, twofold b) {
twofold answer = a-b;
return reply;
}
twofold multiply(double a, twofold b) {
twofold answer = a*b;
return reply;
}
twofold divide(double a, twofold b) {
twofold answer = a/b;
return reply;
}
twofold power(double a, twofold b){
twofold answer =a;
for (int x=2; x<=b; x++){
answer *= a;
}
return reply;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.