• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

intmainale / ProgettoMTSS2 / #4

07 May 2025 06:03PM UTC coverage: 85.714%. First build
#4

push

intmainale
Merge branch 'release/1.0'

30 of 35 new or added lines in 2 files covered. (85.71%)

30 of 35 relevant lines covered (85.71%)

0.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.91
/src/main/java/it/unipd/mtss/IntegerToRoman.java
1
////////////////////////////////////////////////////////////////////
2
// Stefano Longhena 2111936
3
// Alessandro Savio 2101046
4
////////////////////////////////////////////////////////////////////
5

6
package it.unipd.mtss;
7

NEW
8
public class IntegerToRoman {
×
9

10
    public static String convert(int number) {
11
        if (number <= 0 || number > 1000) {
1✔
12
            throw new IllegalArgumentException("Input must be between 1 and 1000");
1✔
13
        }
14

15
        // Array di mappature tra numeri interi e numeri romani
16
        int[] values = {
1✔
17
            1000, 900, 500, 400,
18
            100, 90, 50, 40,
19
            10, 9, 5, 4,
20
            1
21
        };
22
        String[] numerals = {
1✔
23
            "M", "CM", "D", "CD",
24
            "C", "XC", "L", "XL",
25
            "X", "IX", "V", "IV",
26
            "I"
27
        };
28

29
        StringBuilder result = new StringBuilder();
1✔
30

31
        for (int i = 0; i < values.length; i++) {
1✔
32
            while (number >= values[i]) {
1✔
33
                number -= values[i];
1✔
34
                result.append(numerals[i]);
1✔
35
            }
36
        }
37

38
        return result.toString();
1✔
39
    }
40
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc