Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package SimpleOperationsAndCalculationsExercise;
- import java.util.Scanner;
- public class GoingHomeExam {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int km = Integer.parseInt(scan.nextLine());
- int costFuelKm = Integer.parseInt(scan.nextLine());
- double priceFuelLiter = Double.parseDouble(scan.nextLine());
- double money = Double.parseDouble(scan.nextLine());
- double costFuelCar = km * (costFuelKm / 100);
- double sumCost = costFuelCar * priceFuelLiter;
- if (money >= sumCost) {
- money = money - sumCost;
- System.out.printf("You can go home. %.2f money left.", money);
- } else {
- System.out.printf("Sorry, you cannot go home. Each will receive %.2f money.",money /5 );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement