Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Demo {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double destination = Double.parseDouble(scanner.nextLine());
- double consumption = Double.parseDouble(scanner.nextLine());
- double fuelPrice = Double.parseDouble(scanner.nextLine());
- double money = Double.parseDouble(scanner.nextLine());
- double carConsump = destination * (consumption / 100);
- double moneyNeeded = carConsump * fuelPrice;
- if (money >= moneyNeeded) {
- double result = money - moneyNeeded;
- System.out.printf("You can take a trip. %.2f money left.", result);
- } else {
- double result = moneyNeeded - money;
- double resultother = result / 4;
- System.out.printf("Sorry, you cannot take a trip. Each will receive %.2f money.", resultother);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement