Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Rent {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int months = Integer.parseInt(sc.nextLine());
- int percent = Integer.parseInt(sc.nextLine());
- double priceRentMonth = Double.parseDouble(sc.nextLine());
- double totalPrice = 0;
- double priceSecondHalf = 0;
- double priceFirstHalf = 0;
- if (months % 2 == 0) {
- priceFirstHalf = priceRentMonth * (months * 1.0 / 2);
- priceSecondHalf = (priceRentMonth - priceRentMonth * 0.2) * (months * 1.0 / 2);
- } else {
- priceFirstHalf = priceRentMonth * months / 2;
- priceSecondHalf = (priceRentMonth - priceRentMonth * 0.2) * Math.round(months * 1.0 / 2);
- }
- totalPrice = priceFirstHalf + priceSecondHalf;
- totalPrice += totalPrice * (percent * 1.0 / 100);
- System.out.printf("Total: %.2f", totalPrice);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement