Answer:
1. Code:
import java.util.*;
public class serviceStation
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
//User inputs
System.out.println("Enter the litres of gasoline you want: ");
int gas =sc.nextInt();
System.out.println("Enter the type of gasoline \\R->regular \\U->unleaded \\S->super unleaded \\N->none");
char type = sc.next().charAt(0);
//Convert the character inputs to lowercase
type = Character.toUpperCase(type);
System.out.println("Car wash desired? (Y or N)");
char wash = sc.next().charAt(0);
//Convert the character inputs to lowercase
wash = Character.toUpperCase(wash);
String s1 = "" ,s2 = "";
//Check for type of gas
double total = 0.0;
if(type == 'R')
{
total = total + gas* 16.25;
s1 = "Regular";
}
else if(type == 'U')
{
total = total + gas*17.63 ;
s1 = "Unleaded";
}
else if(type == 'S')
{
total = total + gas*19.50 ;
s1 = "Super Unleaded";
}
else if(type == 'N')
{
total = total + gas*0 ;
s1 = "No gas taken";
}
double fees = 0.0;
//Check if wash is desired
if(wash == 'Y')
{
if(total >= 200)
{
fees = total + 40.0;
s2 = "Yes";
}
else
{
fees = total + 70.0;
s2 = "Yes";
}
}
else
{
fees = total;
s2 = "No";
}
//print billing details
System.out.println("\\ Billing Details:");
System.out.println("Litres of Gasoline: " + gas);
System.out.println("Type of Gasoline: " + s1);
System.out.println("Car Wash desired: " + s2);
System.out.println("Total Cost: K" + fees);
Step-by-step explanation: