Get reliable answers to your questions at Westonci.ca, where our knowledgeable community is always ready to help. Explore a wealth of knowledge from professionals across various disciplines on our comprehensive Q&A platform. Explore comprehensive solutions to your questions from knowledgeable professionals across various fields on our platform.
Sagot :
Answer:
import java.util.Scanner;
public class MoveEstimator
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
final int BASE_RATE = 200, RATE_PER_HOUR = 150, RATE_PER_MILE = 2;
int hours, miles;
double totalFee = 0.0;
System.out.print("Enter the number of hours for a job: ");
hours = input.nextInt();
System.out.print("Enter the number of miles: ");
miles = input.nextInt();
totalFee = BASE_RATE + (hours * RATE_PER_HOUR) + (miles * RATE_PER_MILE);
System.out.printf("For a move taking %d hours and going %d miles the estimate is $%.2f", hours, miles, totalFee);
}
}
Explanation:
*The code is in Java.
Create the Scanner object to be able to get input
Initialize the constant values using final keyword, BASE_RATE, RATE_PER_HOUR, RATE_PER_MILE
Declare the variables, hours, miles, totalFee
Ask the user to enter the hours and miles
Calculate the totalFee, add BASE_RATE, multiplication of hours and RATE_PER_HOUR, multiplication of miles and RATE_PER_MILE
Print the output as in required format
The program named MoveEstimator that prompts a user for and accepts estimates for the number of hours for a job and the number of miles involved in the move and displays the total moving fee is as follows:
x = int(input("number of hours for the job "))
y = int(input("number of miles involved "))
def MoveEstimator(x, y):
return 200 + 150*x + 2*y
print(MoveEstimator(x, y))
Code explanation:
- The first line of code used the variable, x to store the input of the hours for the job
- The second line of code is used to store the input of the number of miles travelled.
- Then, we define a function that accept the users inputs(argument) as variable x and y.
- Then return the mathematical operation to find the total moving fee.
- Finally, we call the function with a print statement.
learn more on python code here: https://brainly.com/question/22841107
We appreciate your visit. Our platform is always here to offer accurate and reliable answers. Return anytime. Thank you for visiting. Our goal is to provide the most accurate answers for all your informational needs. Come back soon. We're glad you chose Westonci.ca. Revisit us for updated answers from our knowledgeable team.