Hey guys i need help with this assigment is for COP2250 Java programing. it looks long but it is only 1 question. i need this ASAP. thank you
Suppose you are writing a program for a gasoline station owner who sells three grades of gasoline products: regular, premium, and super unleaded. Your program reads (R. P. or S) that designates which kind of gasoline was purchased. Using the switch statement, the following program determines the type of gasoline that was purchased. Here is the class that determines the type of petrol and the cost. class Petrol char gas: String type: double amount, cost; Petrol(char ch, double a) gas-ch; amounta: 1 void calculateCosto switch(gas) case 'r': case 'R': type="Regular": break; case 'p': case 'P: type="Premium": break; case 's': case 'S': type "Super": break; default: type="Unknown": break; } public String toStringo 1 return type.equalsignoreCase("Unknown")? "Petrol is " + type + " cannot be served": "The type of petrol that will be served is " + type; } Test your program with the following class. import javax.swing.JOptionPane: class Test Petrol public static void main(Stringilarg) String str -- JOptionPane.show Input Dialog("COP2210 Petrol Station" + " Enter the type of petrol" +"nr/R - for regular gas" "mp/P - for premium gas" A/S - for super gas"); charchstr.charAt(0); str-JOptionPane.showinputDialog("Enter the amount of gas to be purchased"); float amount Float parseFloat(str): Petrol pnew Petroleh, amount): p.calculateCosto: JOptionPane.show MessageDialog(null, p.toString(): Suppose that the cost for each grade of petrol is $2.99 $1.15, and $3.25, respectively, the program should read the amount of petrol sold and calculates each customer's bill The petrol station owner is a generous person, as such the following rewards are given: If a customer purchases 10 gallons of petrol or more, free wash is offered. If the petrol purchased is regular: "You get free wash excluding under carriage and wheels": If the petrol purchased is premium: "You get free wash excluding under carriage": If the petrol purchased is super: "You get free super wash": Modify the program to include the following features: (a) Constant declarations as follows in the class called Petrol.java: static final float REGULAR GAS -2.997: static final float PREMIUM GAS -3.15: static final float SUPER_GAS -3.25 static final String REGULAR_WASH - "You get free wash excluding under carriage and static final String REGULAR_WASH -"You get free wash excluding under carriage": static final String REGULAR WASH -"You get free super wash": (b) Include the following variable String free. This variable stores the one of the sentences above. (c) Modify the case statements that have valid petrol type, to include: Determining whether or not the customer gets free wash Calculate the cost for the amount of petrol purchased. For instance caser: case 'R': type "Regular": cost - amount regular: if (amount > 10) 2 free = REGULAR_WASH; break; (d) Modify the method String toString() to reflect the customer's bill. That is: public String toStringo { if (type.equals("Unknown")) return "Petrol is " + type + " cannot be served"; else return "The type of petrol that will be served is " + type +" Your bill is: $" + cost + " " + free; 3 Test the program with the following data: R D s 15 20 5 10 When you have completed the program, do the following: Demonstrate your program to the lab instructor Print a copy of the program along with sample output and submit it to the lab instructor