private static void Dieselfuel(double fuel) throws FileNotFoundException { // TODO Auto-generated method stub
scan2 = new Scanner(System.in);
double integer1;
double sum;
DecimalFormat df = new DecimalFormat("###.#");
integer1 = 1.30;
sum = integer1 * fuel;
So this is the receipt to show the user how much he/she entered the requested amount of fuel.
LocalDateTime myDateObj = LocalDateTime.now();
DateTimeFormatter myFormatObj = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss");
String formattedDate = myDateObj.format(myFormatObj);
System.out.println("");
System.out.println(" RECEIPT");
System.out.println("JLT's Garage "+" DATE: " + formattedDate);
System.out.println("__________________________________________________________");
System.out.println("| Item Description | Amount (per/litre) | Price |");
System.out.println("|‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾|‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾|‾‾‾‾‾‾‾‾‾‾‾|");
System.out.println("| Diesel fuel |"+" " + fuel +" |" + " £" + df.format(sum) + " |");
System.out.println("|_____________________|_______________________|___________| ");
System.out.println(" Total cost: £ " + df.format(sum));
System.out.println("Thanks for using our service (: ");
System.out.println("");
return;
}
public static void Unleaded(String c, double fuel) throws FileNotFoundException {
// TODO Auto-generated method stub
scan2 = new Scanner(System.in);
{
// initialization expression
int i = 1;
// test expression
while (i < 111111) {
System.out.println("----- Standby -----");
// update expression
i++;
}
}
{
// initialization expression
int i2 = 1;
// test expression
while (i2 < 70000) {
System.out.println("----- Ready -----");
// update expression
i2++;
}
}
System.out.println("");
System.out.println("|‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾|");
System.out.println("| JLT's Garage |");
System.out.println("| The avaliable pumps; |");
System.out.println("|_______________________|");
System.out.println("| 01 | In use |");
System.out.println("| 02 | Idle |");
System.out.println("| 03 | Idle |");
System.out.println("| 04 | Idle |");
System.out.println("| 05 | Idle |");
System.out.println("| 06 | Idle |");
System.out.println("| 07 | Idle |");
System.out.println("| 08 | Idle |");
System.out.println("| 09 | Idle |");
System.out.println("| 10 | Idle |");
System.out.println("‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾");
{
System.out.println("");
System.out.println("The cost for V-Power Petrol per litre is currently £1.27 - Please eneter the amount of litre you need");
**fuel = input.nextDouble();**
**// I need to print this users value to print out in Dieselfuel class. It's like an receipt transaction to allow him/she to access the receipt again.
{
// initialization expression
int i3 = 1;
// test expression
while (i3 < 90000) {
System.out.println("----- Standby -----");
System.out.println();
// update expression
i3++;
}
}
System.out.println("Ok, here is your fuel; " + fuel + " litre");
{
System.out.println("Would you still ike to continue with this transaction, yes or no?");
c = input.next();
{
// initialization expression
int i3 = 1;
// test expression
while (i3 < 90000) {
System.out.println("----- Idle -----");
// update expression
i3++;
}
{
if(c.equalsIgnoreCase("y") || c.equalsIgnoreCase("yes"))
{
Unleadedfuel(fuel);
return;
} else {
if(c.equalsIgnoreCase("n") || c.equalsIgnoreCase("no"))
{
System.out.println("");
System.out.println("Thank you, for using our service.");
System.out.println("");
return;
}
}
}
}
}
}
}
Aucun commentaire:
Enregistrer un commentaire