Question
Write a Java program that interacts with a user by printing out a list of pollutants and requests input from the user as follows: 1.Carbon
Write a Java program that interacts with a user by printing out a list of pollutants and requests input from the user as follows:
1.Carbon monoxide
2.Hydrocarbons
3.Nitrogen oxides
4.Non-methane hydrocarbons
Enter pollutant number =>
Enter number of grams emitted per mile =>
Enter odometer reading =>
Use this table of emissions limits to determine the appropriate output message.
Maximum allowed for the first 50000 miles Maximum allowed for the next 50000 miles
0milage50000 50000 Carbon Monoxide 3.4 grams/mile 4.2 grams/mile Hydrocarbons 0.31 grams/mile 0.39 grams/mile Nitrogen Oxides 0.4 grams/mile 0.5 grams/mile Nonmethane hydrocarbons .25 grams/mile .31 grams/mile To receive full credit for this project, you must include, one switch statement nested if-control structure Write a static method with the following header line and arguments: public static boolean mileageGramsLogic( int actualMileage, int firstMileageLimit, int secondMileageLimit, double actualGrams, double firstGramLimit, double secondGramLimit ) (See the next page for more instructions.) Run your program for these three different cases: Enter pollutant number => 2 Enter number of grams emitted per mile => 0.35 Enter odometer reading => 40112 Enter pollutant number => 3 Enter number of grams emitted per mile => 0.61 Enter odometer reading => 101000 Enter pollutant number => 4 Enter number of grams emitted per mile => 0.27 Enter odometer reading => 60200 The mileagGrams Logic return a Boolean: either the emission amount is or is not within the permitted limit. Print messages like this: Emissions exceed the permitted level. Emissions are within the permitted level. Note there is no emission limit for mileage beyond 100,000 miles. Include an appropriate comment header public class EmissionsLab5 { public static void main( String [] args ) { // Declare ALL your variables here: int pollutantNumber = 0; int firstGramLimit; // display the 4 pollutant choices: CO, HC, NO, other System.out.println( " " ); // Prompt for the three inputs: pollutant #, grams, mileage System.out.print( " " ); // Create a switch switch ( pollutantNumber ) { case 1: // firstGramLimit = 3.4; // case 2: } boolean result = false; // = mileageGramsLogic( ); if ( result ) { // display message } else { // display other message } } // end main public static boolean mileageGramsLogic( ) { // use a nested-if control structure and separate the // logic for mileage and pollutant grams. return false ; // fix this. } // end method } // end class
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started