-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMixedRainbow.java
More file actions
31 lines (28 loc) · 998 Bytes
/
MixedRainbow.java
File metadata and controls
31 lines (28 loc) · 998 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.util.Scanner;
/*
* This code lets the user to enter all colours of rainbow.
* The code replaces each letters "e" by letter "a".
* The code then makes every letter uppercase in each second colour.
* Finally all colours are outputed
*/
public class MixedRainbow {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
String[] colours = new String[7];
System.out.println("Enter all rainbow colours (press enter after each entered): ");
for(int i = 0; i < 7; i++){
colours[i] = scanner.nextLine();
colours[i] = colours[i].replaceAll("e","a");
if(i % 2 != 0){
colours[i] = colours[i].toUpperCase();
}else{
colours[i] = colours[i].toLowerCase();
}
}
System.out.println("Here is the result:");
for(int i = 0; i < 7; i++){
System.out.println(colours[i]);
}
scanner.close();
}
}