Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.carDealer.controllers;
- import java.util.Scanner;
- public class t {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- //input
- long start = Integer.parseInt(sc.nextLine());
- long end = Integer.parseInt(sc.nextLine());
- String str = sc.nextLine();
- long sum = 0;
- for (long i = start; i < end; i++) {
- if (i % 5 == 0) {
- sum += i;
- } else {
- sum += (i % 5);
- }
- }
- String sumStr = String.valueOf(sum);
- if (sum % 2 == 0) {
- String charToReplace = String.valueOf(sumStr.charAt(0));
- System.out.printf("%s", sumStr.replaceAll(charToReplace, str));
- } else {
- String charToReplace = String.valueOf(sumStr.charAt(sumStr.length() - 1));
- System.out.printf("%s", sumStr.replaceAll(charToReplace, str));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement