Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SpecialCarNumbers {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n1 = Integer.parseInt(scanner.nextLine());
- int n2 = Integer.parseInt(scanner.nextLine());
- int n3 = Integer.parseInt(scanner.nextLine());
- int n4 = Integer.parseInt(scanner.nextLine());
- int totalMoney = 0;
- int c3num = 0;
- int c4num = 0;
- for (int i = 0; i <= n1; i++) {
- for (int j = 0; j <= n2; j++) {
- for (int k = 0; k <= n3; k++) {
- for (int l = 0; l <= n4; l++) {
- System.out.println(""+i+j+k+l);
- if (!(i == j || i == k || i == l || j == k || j == l || k == l)){
- totalMoney += 20;
- } else if ((i == j && j != k && j == l) || (i == k && j != k && k == l) ){
- totalMoney += 20;
- } else if ((i == j && i == k && i != l) || (j == k & j == l && i != j)){
- totalMoney += 100;
- c3num++;
- } else if (i == j && j == k && k == l){
- totalMoney += 1000;
- c4num++;
- } else {
- totalMoney += 20;
- }
- }
- }
- }
- }
- System.out.printf("Final sum: %dlv.%n",totalMoney);
- System.out.printf("Car numbers with 3 equal digits: %d%n",c3num);
- System.out.printf("Car numbers with 4 equal digits: %d",c4num);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement