Question

In: Computer Science

JAVA please Program 4: Is there a Prius version? Did you know that the average Boeing...

JAVA please

Program 4: Is there a Prius version? Did you know that the average Boeing 747 airplane uses approximately 1 gallon of fuel per second? Given the speed of the airplane, that means it gets 5 gallons to the mile. No, not 5 miles to the gallon, 5 gallons to the mile. You may be questioning why such a horribly inefficient machine is allowed to exist, but you’ll be happy to find out that, because this airplane hold 568 people, it averages about 0.01 gallons per person – (100 miles per gallon per person). Your job is to design (pseudocode) and implement (source code) a program that asks the user for a distance the plane has to fly (i.e. the length of the trip) and also asks the cost of jet fuel (which is currently $1.80 per gallon). The program should then calculate the total fuel charges to make the trip. Next, ask the user how many people will fly, as well as the average cost of a ticket. Finally, print the total profit made (or lost) and the average gas mileage per person. Document your code and properly label the input prompts and the outputs as shown below.

Solutions

Expert Solution

Thanks for the question.

Here is the completed code for this problem. 


Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. 


If you are satisfied with the solution, please rate the answer. 


Thanks


===========================================================================
import java.util.Scanner;

public class ProblemFour {

    private static final double GALLON_PER_SECOND=5.0;

    public static void main(String[] args) {

        // scanner object to accept user input
        Scanner scanner = new Scanner(System.in);

        double flightDistance;
        double fuelCost;
        int passengersInFlight=0;
        double averageTicketCost =0;


        // take user inputs
        System.out.print("Enter the flight distance: ");
        flightDistance=scanner.nextDouble();

        System.out.print("Enter the current cost of jet fuel: $");
        fuelCost = scanner.nextDouble();

        double flightCost = flightDistance*fuelCost*GALLON_PER_SECOND;
        System.out.println("The flight will cost $"+String.format("%.1f",flightCost)+" in fuel");
        System.out.print("Enter the number of passengers: ");
        passengersInFlight = scanner.nextInt();


        System.out.print("Enter the average cost of a ticket: ");
        averageTicketCost = scanner.nextDouble();

        // calculate profit Selling Price - Cost Price
        double profit = passengersInFlight*averageTicketCost-flightCost;

        System.out.println("You will make a profit of $"+String.format("%.1f",profit));

        // calculate average miles per person
        double averageMilesPerPerson = passengersInFlight/GALLON_PER_SECOND;
        System.out.println("You averaged "+String.format("%.1f",averageMilesPerPerson)
        + " miles per person per gallon!");
    }
}

=============================================================================

thank you & please do up vote for me

regards,

friend : )


Related Solutions

IN JAVA PLEASE Program 4: Is there a Prius version? Did you know that the average...
IN JAVA PLEASE Program 4: Is there a Prius version? Did you know that the average Boeing 747 airplane uses approximately 1 gallon of fuel per second? Given the speed of the airplane, that means it gets 5 gallons to the mile. No, not 5 miles to the gallon, 5 gallons to the mile. You may be questioning why such a horribly inefficient machine is allowed to exist, but you’ll be happy to find out that, because this airplane hold...
PLEASE DO THIS IN C#.Is there a Prius version? Did you know that the average Boeing...
PLEASE DO THIS IN C#.Is there a Prius version? Did you know that the average Boeing 747 airplane uses approximately 1 gallon of fuel per second? Given the speed of the airplane, that means it gets 5 gallons to the mile. No, not 5 miles to the gallon, 5 gallons to the mile. You may be questioning why such a horribly inefficient machine is allowed to exist, but you’ll be happy to find out that, because this airplane hold 568...
IN C++ LANGUAGE PLEASE:::: Is there a Prius version? Did you know that the average Boeing...
IN C++ LANGUAGE PLEASE:::: Is there a Prius version? Did you know that the average Boeing 747 airplane uses approximately 1 gallon of fuel per second?  Given the speed of the airplane, that means it gets 5 gallons to the mile. No, not 5 miles to the gallon, 5 gallons to the mile.   You may be questioning why such a horribly inefficient machine is allowed to exist, but you’ll be happy to find out that, because this airplane hold 568 people, it...
PLEASE ANSWER USING C# Is there a Prius version? Did you know that the average Boeing...
PLEASE ANSWER USING C# Is there a Prius version? Did you know that the average Boeing 747 airplane uses approximately 1 gallon of fuel per second? Given the speed of the airplane, that means it gets 5 gallons to the mile. No, not 5 miles to the gallon, 5 gallons to the mile. You may be questioning why such a horribly inefficient machine is allowed to exist, but you’ll be happy to find out that, because this airplane hold 568...
Please do in java Program 3: Give a baby $5,000! Did you know that, over the...
Please do in java Program 3: Give a baby $5,000! Did you know that, over the last century, the stock market has returned an average of 10%? You may not care, but you’d better pay attention to this one. If you were to give a newborn baby $5000, put that money in the stock market and NOT add any additional money per year, that money would grow to over $2.9 million by the time that baby is ready for retirement...
you will create a program with Java to implement a simplified version of RSA cryptosystems. To...
you will create a program with Java to implement a simplified version of RSA cryptosystems. To complete this project, you may follow the steps listed below (demonstrated in Java code) to guide yourself through the difficulties. Step I Key-gen: distinguish a prime number (20 pts) The generation of RSA's public/private keys depends on finding two large prime numbers, thus our program should be able to tell if a given number is a prime number or not. For simplicity, we define...
rite a Java Program to play your version of the Texas Pick 3 Lottery. You will...
rite a Java Program to play your version of the Texas Pick 3 Lottery. You will need to include the provided code given below in your program. Task:The program will prompt for a number between 0 and 999. Your program will display the number of attempts it took for the entered number to match a randomly generated number. In the main() method, declare an int named myPick3choice. Create a prompt for myPick3choice as "Enter your Pick 3 choice:0-999". Create a...
FOR #4 A & B I don't know if I did it correctly.....Please check & the...
FOR #4 A & B I don't know if I did it correctly.....Please check & the other questions I'm having a heard time on. Thanks! A. You have been given a tube of E. coli. You are asked to make 1 mL total volume of 10-1 dilution of the bacterial culture. Explain how you would do this. Show all necessary calculations. ____ ml cells   +    _____ ml water    = 1 ml    (total volume) V1 D1 X V2 D2 1 mL...
Calculate Interest in a Java program. If you know the balance and the annual percentage interest...
Calculate Interest in a Java program. If you know the balance and the annual percentage interest rate, you can compute the interest on the next monthly payment using the following formula: interest = balance * (annualInterestRate/1200) Write a program that reads the balance and the annual percentage interest rate and displays the interest for the next month. Create a scanner Prompt the user to enter a name and create variable for scanner Prompt the user to enter a balance and...
The following is a C program that is a video game version of Connect 4. The...
The following is a C program that is a video game version of Connect 4. The code works fine as is now but I want to change the way you input which column you drop a disk into. Currently, you type in 1 and it goes into column 1. If you type in 6, it goes into column 6 and so on. But I want to make it so you input A or a, then it goes into column 1...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT