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 scanner = new Scanner(System.in);
- int months = Integer.parseInt(scanner.nextLine());
- int percent = Integer.parseInt(scanner.nextLine());
- double rentForMonth = Double.parseDouble(scanner.nextLine());
- double firstMonths = 0.0;
- double secondMonths = 0.0;
- if (months % 2 == 0) {
- firstMonths = (months / 2) * rentForMonth;
- secondMonths = ((months / 2) * rentForMonth) - (months / 2) * (rentForMonth * 0.2);
- } else {
- firstMonths = (months / 2) * rentForMonth;
- secondMonths = (((months / 2) + 1) * rentForMonth) - ((months / 2) + 1) * (rentForMonth * 0.2);
- }
- double totalSum = firstMonths + secondMonths;
- double broker = totalSum * (percent * 1.0 / 100);
- double finalSum = totalSum + broker;
- System.out.printf("Total: %.2f", finalSum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement